Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,4 @@ node_modules
*-lock.*
.vscode
lib/
.github/instructions/wmt-copilot.instructions.md
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 <!-- omit in toc -->

Expand Down Expand Up @@ -496,7 +496,7 @@ identity (no compression)

```js
server: {
bodyLimit: 1048576; //new size limit
bodyLimit: 1048576 // new size limit in bytes (1MB)
}
```

Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -95,4 +95,4 @@
],
"recursive": true
}
}
}
27 changes: 22 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions test/sample/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable */

"use strict";
const fastifyPlugin = require("fastify-plugin");
const path = require("path");
Expand Down Expand Up @@ -60,4 +58,5 @@ const config = {
});
}
};
require("../../")(config);
const { electrodeServer } = require("../../");
electrodeServer(config);