diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77e552c..b8ed4bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [16.x, 18.x, 20.x, 22.x] + node: [20.x, 22.x] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 diff --git a/.gitignore b/.gitignore index 38cb1a3..d389a99 100644 --- a/.gitignore +++ b/.gitignore @@ -142,3 +142,4 @@ node_modules *-lock.* .vscode lib/ +.github/instructions/wmt-copilot.instructions.md diff --git a/README.md b/README.md index 6b04b87..12bf5b7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] -This is an imaginatively named, configurable web server using Fastify atop Node.js. +This is an imaginatively named, configurable web server using Fastify 5.x atop Node.js. The aim is to provide a standardized node web server that can be used to serve your web application without the need for duplicating from another example, or starting from scratch. @@ -11,7 +11,7 @@ The intention is that you will extend via configuration, such that this provides functionality of a Fastify web server, and within your own application you will add on the features, logic, etc unique to your situation. -This module requires Node v16.x.x+. +This module requires Node v20.x.x+ and supports Fastify 5.x. ## Table Of Contents @@ -496,7 +496,7 @@ identity (no compression) ```js server: { - bodyLimit: 1048576; //new size limit + bodyLimit: 1048576 // new size limit in bytes (1MB) } ``` diff --git a/package.json b/package.json index 3122cff..00a9894 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@xarc/fastify-server", - "version": "4.0.10", + "version": "5.0.0-beta.0", "description": "A configurable Fastify web server", "main": "lib/index.js", "types": "./lib/index.d", @@ -45,19 +45,19 @@ ], "license": "Apache-2.0", "engines": { - "node": ">= 14.0.0" + "node": ">= 22.0.0" }, "files": [ "lib", "src" ], "dependencies": { - "@fastify/static": "^7.0.4", + "@fastify/static": "^8.2.0", "async-eventemitter": "^0.2.4", "chalk": "^4.1.0", "electrode-confippet": "^1.7.0", - "fastify": "^4.29.0", - "fastify-plugin": "^4.5.0", + "fastify": "^5.6.1", + "fastify-plugin": "^5.0.1", "lodash": "^4.17.21", "require-at": "^1.0.6", "tslib": "^2.1.0", @@ -68,7 +68,7 @@ "@istanbuljs/nyc-config-typescript": "^1.0.1", "@types/jest": "^29.5.11", "@types/mocha": "^8.2.0", - "@types/node": "^14.14.16", + "@types/node": "^22.0.0", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", "eslint": "^7.16.0", @@ -78,7 +78,7 @@ "jest": "^29.7.0", "mitm": "^1.2.0", "npm-run-all": "4.1.5", - "prettier": "3.2.4", + "prettier": "^3.6.0", "run-verify": "^1.2.1", "source-map-support": "^0.5.19", "superagent": "^9.0.2", @@ -95,4 +95,4 @@ ], "recursive": true } -} +} \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 988f4ff..37fb0d9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -94,10 +94,7 @@ export type { } from "fastify"; /* eslint-enable max-len */ -export type ServerInfo = { - address: string; - port: number; -}; +export type ServerInfo = { address: string; port: number }; export interface ElectrodeFastifyInstance extends FastifyInstance { info: ServerInfo; @@ -204,7 +201,27 @@ export type ElectrodeServerConfig = { * ``` */ plugins?: PluginsConfig; - /** options to be passed to fastify verbatim */ + /** + * options to be passed to fastify verbatim + * + * **Note for Fastify 5 migration:** + * - `requestIdHeader` now defaults to `false` instead of `"request-id"` + * - Router options like `maxParamLength`, `ignoreTrailingSlash`, etc. should be + * moved under `routerOptions` to avoid deprecation warnings + * - Example: + * ```js + * { + * server: { + * requestIdHeader: false, // explicit default in Fastify 5 + * routerOptions: { + * maxParamLength: 1000, + * ignoreTrailingSlash: false, + * caseSensitive: true + * } + * } + * } + * ``` + */ server?: FastifyServerOptions; /** settings specific to Electrode's add-ons for the fastify server */ electrode?: ElectrodeOptions; diff --git a/test/sample/index.js b/test/sample/index.js index 9d3c76e..43f7a12 100644 --- a/test/sample/index.js +++ b/test/sample/index.js @@ -1,5 +1,3 @@ -/* eslint-disable */ - "use strict"; const fastifyPlugin = require("fastify-plugin"); const path = require("path"); @@ -60,4 +58,5 @@ const config = { }); } }; -require("../../")(config); +const { electrodeServer } = require("../../"); +electrodeServer(config);