Skip to content

Commit fba8c44

Browse files
committed
feat!: Dropped support for Node 18 and updated dependencies.
1 parent 16e409c commit fba8c44

13 files changed

+41
-43
lines changed

.eslintrc.json

-7
This file was deleted.

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
steps:
88
- name: Checkout
99
uses: actions/checkout@v3
10-
- name: Use Node.js LTS
10+
- name: Use supported Node.js Version
1111
uses: actions/setup-node@v3
1212
with:
13-
node-version: lts/*
13+
node-version: 20.18.0
1414
- name: Restore cached dependencies
1515
uses: actions/cache@v3
1616
with:

.swcrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"jsc": {
3-
"target": "es2022",
3+
"target": "esnext",
44
"parser": {
55
"syntax": "typescript",
66
"tsx": false,

eslint.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { cowtech } from '@cowtech/eslint-config'
2+
3+
export default [
4+
...cowtech,
5+
{
6+
languageOptions: {
7+
parserOptions: {
8+
project: './tsconfig.test.json'
9+
}
10+
}
11+
}
12+
]

package.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,35 @@
3333
"build": "swc --strip-leading-paths --delete-dir-on-start -d dist src",
3434
"postbuild": "concurrently npm:lint npm:typecheck",
3535
"format": "prettier -w src test",
36-
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx src test",
36+
"lint": "eslint --cache",
3737
"typecheck": "tsc -p . --emitDeclarationOnly",
38-
"test": "c8 -c test/config/c8-local.json node --import tsx --test test/*.test.ts",
39-
"test:ci": "c8 -c test/config/c8-ci.json node --import tsx --test-reporter=tap --test test/*.test.ts",
38+
"test": "c8 -c test/config/c8-local.json node --env-file=test.env --test test/*.test.ts",
39+
"test:ci": "c8 -c test/config/c8-ci.json node --env-file=test.env --test-reporter=tap --test test/*.test.ts",
4040
"ci": "npm run build && npm run test:ci",
4141
"prepublishOnly": "npm run ci",
4242
"postpublish": "git push origin && git push origin -f --tags"
4343
},
4444
"dependencies": {
45-
"ajv": "^8.12.0",
46-
"fastify-plugin": "^4.5.1",
47-
"http-errors-enhanced": "^2.0.8"
45+
"ajv": "^8.17.1",
46+
"fastify-plugin": "^5.0.1",
47+
"http-errors-enhanced": "^3.0.0"
4848
},
4949
"devDependencies": {
50-
"@cowtech/eslint-config": "^9.0.3",
51-
"@swc/cli": "^0.3.12",
52-
"@swc/core": "^1.4.13",
53-
"@types/node": "^20.12.7",
50+
"@cowtech/eslint-config": "10.0.0",
51+
"@swc-node/register": "^1.10.9",
52+
"@swc/cli": "0.4.1-nightly.20240914",
53+
"@swc/core": "^1.7.36",
54+
"@types/node": "^22.7.7",
5455
"ajv-formats": "^3.0.1",
55-
"c8": "^9.1.0",
56-
"chokidar": "^3.6.0",
57-
"concurrently": "^8.2.2",
58-
"eslint": "^8.57.0",
59-
"fastify": "^4.26.2",
60-
"prettier": "^3.2.5",
61-
"tsx": "^4.7.2",
62-
"typescript": "^5.4.5"
56+
"c8": "^10.1.2",
57+
"chokidar": "^4.0.1",
58+
"concurrently": "^9.0.1",
59+
"eslint": "^9.13.0",
60+
"fastify": "^5.0.0",
61+
"prettier": "^3.3.3",
62+
"typescript": "^5.6.3"
6363
},
6464
"engines": {
65-
"node": ">= 18.18.0"
65+
"node": ">= 20.18.0"
6666
}
6767
}

src/handlers.ts

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export function handleErrors(error: FastifyError | Error, request: FastifyReques
9797
addAdditionalProperties(body, error)
9898

9999
// Send the error back
100-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
101100
reply
102101
.code(statusCode)
103102
.headers(headers ?? {})

src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export const plugin = fastifyPlugin(
2727
preHandler: typeof options.preHandler === 'function' ? options.preHandler : undefined
2828
}
2929

30-
instance.decorate(kHttpErrorsEnhancedConfiguration, null)
31-
instance.decorateRequest(kHttpErrorsEnhancedConfiguration, null)
30+
instance.decorate(kHttpErrorsEnhancedConfiguration, undefined)
31+
instance.decorateRequest(kHttpErrorsEnhancedConfiguration, undefined)
3232

3333
instance.addHook('onRequest', (request, _, done) => {
3434
request[kHttpErrorsEnhancedConfiguration] = configuration
@@ -51,7 +51,7 @@ export const plugin = fastifyPlugin(
5151

5252
done()
5353
},
54-
{ name: 'fastify-http-errors-enhanced', fastify: '4.x' }
54+
{ name: 'fastify-http-errors-enhanced', fastify: '5.x' }
5555
)
5656

5757
export default plugin

src/interfaces.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type Ajv from 'ajv'
2-
import { type ValidateFunction } from 'ajv'
1+
import { type Ajv, type ValidateFunction } from 'ajv'
32
import { type FastifyError } from 'fastify'
43

54
export const kHttpErrorsEnhancedConfiguration = Symbol('fastify-http-errors-enhanced-configuration')
@@ -10,7 +9,7 @@ export interface Configuration {
109
convertValidationErrors?: boolean
1110
allowUndeclaredResponses?: boolean
1211
use422ForValidationErrors?: boolean
13-
responseValidatorCustomizer?: (ajv: typeof Ajv) => void
12+
responseValidatorCustomizer?: (ajv: Ajv) => void
1413
preHandler?: (error: FastifyError | Error) => Error
1514
}
1615

test.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NODE_OPTIONS=--import @swc-node/register/esm-register

test/hooks.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises */
2-
31
import fastify, { type FastifyError, type FastifyInstance, type FastifyPluginOptions } from 'fastify'
42
import { INTERNAL_SERVER_ERROR } from 'http-errors-enhanced'
53
import { deepStrictEqual, match } from 'node:assert'

test/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises */
2-
31
import fastify, {
42
type FastifyInstance,
53
type FastifyPluginOptions,

test/utils.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises */
2-
31
import { deepStrictEqual, ifError } from 'node:assert'
42
import { test } from 'node:test'
53
import { get, upperFirst } from '../src/utils.js'

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2022",
3+
"target": "ESNext",
44
"module": "NodeNext",
55
"moduleResolution": "NodeNext",
66
"jsx": "preserve",

0 commit comments

Comments
 (0)