Skip to content

Commit f26e48b

Browse files
committed
feat!: Dropped support for Node 18 and updated dependencies.
1 parent f1a6a35 commit f26e48b

File tree

12 files changed

+42
-42
lines changed

12 files changed

+42
-42
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

+20-20
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,37 @@
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-
"@fastify/static": "^7.0.3",
46-
"fastify-plugin": "^4.5.1",
45+
"@fastify/static": "^8.0.2",
46+
"fastify-plugin": "^5.0.1",
4747
"js-yaml": "^4.1.0",
48-
"swagger-ui-dist": "^5.15.1"
48+
"swagger-ui-dist": "^5.17.14"
4949
},
5050
"devDependencies": {
51-
"@cowtech/eslint-config": "^9.0.3",
52-
"@swc/cli": "^0.3.12",
53-
"@swc/core": "^1.4.13",
51+
"@cowtech/eslint-config": "10.0.0",
52+
"@swc-node/register": "^1.10.9",
53+
"@swc/cli": "0.4.1-nightly.20240914",
54+
"@swc/core": "^1.7.36",
5455
"@types/js-yaml": "^4.0.9",
55-
"@types/node": "^20.12.7",
56-
"@types/swagger-ui-dist": "^3.30.4",
57-
"c8": "^9.1.0",
58-
"chokidar": "^3.6.0",
59-
"concurrently": "^8.2.2",
60-
"eslint": "^8.57.0",
61-
"fastify": "^4.26.2",
62-
"prettier": "^3.2.5",
63-
"tsx": "^4.7.2",
64-
"typescript": "^5.4.5"
56+
"@types/node": "^22.7.7",
57+
"@types/swagger-ui-dist": "^3.30.5",
58+
"c8": "^10.1.2",
59+
"chokidar": "^4.0.1",
60+
"concurrently": "^9.0.1",
61+
"eslint": "^9.13.0",
62+
"fastify": "^5.0.0",
63+
"prettier": "^3.3.3",
64+
"typescript": "^5.6.3"
6565
},
6666
"engines": {
67-
"node": ">= 18.18.0"
67+
"node": ">= 20.18.0"
6868
}
6969
}

src/index.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises */
21
import {
32
type FastifyError,
43
type FastifyInstance,
@@ -8,7 +7,7 @@ import {
87
type RouteOptions
98
} from 'fastify'
109
import fastifyPlugin from 'fastify-plugin'
11-
import yaml from 'js-yaml'
10+
import { dump } from 'js-yaml'
1211
import { buildSpec, type Schema } from './spec.js'
1312
import { addUI } from './ui.js'
1413

@@ -32,7 +31,7 @@ export const plugin = fastifyPlugin(
3231
url: `${prefix}/openapi.yaml`,
3332
handler(_: FastifyRequest, reply: FastifyReply): void {
3433
reply.type('text/yaml')
35-
reply.send(yaml.dump(spec))
34+
reply.send(dump(spec))
3635
},
3736
config: { hide: false }
3837
})
@@ -63,7 +62,7 @@ export const plugin = fastifyPlugin(
6362

6463
done()
6564
},
66-
{ name: 'fastify-openapi-docs', fastify: '4.x' }
65+
{ name: 'fastify-openapi-docs', fastify: '5.x' }
6766
)
6867

6968
export default plugin

src/spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function parseParameters(instance: FastifyInstance, schema: Schema): Schema | un
2323
for (const [section, where] of Object.entries(parametersSections)) {
2424
let specs: Schema = schema[section]
2525

26+
/* c8 ignore next 11 */
2627
// Parameters do not support $ref, so resolve the link
2728
if (specs?.$ref) {
2829
specs = instance.getSchema(specs.$ref as string) as Schema

src/ui.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises */
2-
31
import fastifyStatic from '@fastify/static'
42
import { type FastifyInstance, type FastifyReply, type FastifyRequest } from 'fastify'
53
import { readFileSync } from 'node:fs'
@@ -25,7 +23,7 @@ export function addUI(instance: FastifyInstance, prefix: string): void {
2523
method: 'GET',
2624
url: prefix,
2725
handler(_: FastifyRequest, reply: FastifyReply): void {
28-
reply.redirect(301, indexUrl)
26+
reply.redirect(indexUrl, 301)
2927
}
3028
})
3129

test.env

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

test/spec.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 FastifyReply, type FastifyRequest } from 'fastify'
42
import { deepStrictEqual } from 'node:assert'
53
import { test } from 'node:test'

test/ui.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 from 'fastify'
42
import { deepStrictEqual, ok } from 'node:assert'
53
import { test } from 'node:test'

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)