Skip to content

Commit 8bacf26

Browse files
RahulTinkuRahul Kumar
andauthored
Fastify 5 (#48)
* feat: fastify 5 upgrade * build: rebuil * feat: fastify 5 upgrade- beta publish * Update ci.yml remove node 16 and 18 ci check, as fastify 5 support node 20+ * build: rebuild after ci:check * feat: beta publish version --------- Co-authored-by: Rahul Kumar <rahul.kumar1@walmart.com>
1 parent 1eaee86 commit 8bacf26

6 files changed

Lines changed: 37 additions & 20 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
node: [16.x, 18.x, 20.x, 22.x]
15+
node: [20.x, 22.x]
1616
steps:
1717
- uses: actions/checkout@v4
1818
- uses: actions/setup-node@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,4 @@ node_modules
142142
*-lock.*
143143
.vscode
144144
lib/
145+
.github/instructions/wmt-copilot.instructions.md

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
44

5-
This is an imaginatively named, configurable web server using Fastify atop Node.js.
5+
This is an imaginatively named, configurable web server using Fastify 5.x atop Node.js.
66

77
The aim is to provide a standardized node web server that can be used to serve your web
88
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
1111
functionality of a Fastify web server, and within your own application you will add on the
1212
features, logic, etc unique to your situation.
1313

14-
This module requires Node v16.x.x+.
14+
This module requires Node v20.x.x+ and supports Fastify 5.x.
1515

1616
## Table Of Contents <!-- omit in toc -->
1717

@@ -496,7 +496,7 @@ identity (no compression)
496496

497497
```js
498498
server: {
499-
bodyLimit: 1048576; //new size limit
499+
bodyLimit: 1048576 // new size limit in bytes (1MB)
500500
}
501501
```
502502

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xarc/fastify-server",
3-
"version": "4.0.10",
3+
"version": "5.0.0-beta.0",
44
"description": "A configurable Fastify web server",
55
"main": "lib/index.js",
66
"types": "./lib/index.d",
@@ -45,19 +45,19 @@
4545
],
4646
"license": "Apache-2.0",
4747
"engines": {
48-
"node": ">= 14.0.0"
48+
"node": ">= 22.0.0"
4949
},
5050
"files": [
5151
"lib",
5252
"src"
5353
],
5454
"dependencies": {
55-
"@fastify/static": "^7.0.4",
55+
"@fastify/static": "^8.2.0",
5656
"async-eventemitter": "^0.2.4",
5757
"chalk": "^4.1.0",
5858
"electrode-confippet": "^1.7.0",
59-
"fastify": "^4.29.0",
60-
"fastify-plugin": "^4.5.0",
59+
"fastify": "^5.6.1",
60+
"fastify-plugin": "^5.0.1",
6161
"lodash": "^4.17.21",
6262
"require-at": "^1.0.6",
6363
"tslib": "^2.1.0",
@@ -68,7 +68,7 @@
6868
"@istanbuljs/nyc-config-typescript": "^1.0.1",
6969
"@types/jest": "^29.5.11",
7070
"@types/mocha": "^8.2.0",
71-
"@types/node": "^14.14.16",
71+
"@types/node": "^22.0.0",
7272
"@typescript-eslint/eslint-plugin": "^5.0.0",
7373
"@typescript-eslint/parser": "^5.0.0",
7474
"eslint": "^7.16.0",
@@ -78,7 +78,7 @@
7878
"jest": "^29.7.0",
7979
"mitm": "^1.2.0",
8080
"npm-run-all": "4.1.5",
81-
"prettier": "3.2.4",
81+
"prettier": "^3.6.0",
8282
"run-verify": "^1.2.1",
8383
"source-map-support": "^0.5.19",
8484
"superagent": "^9.0.2",
@@ -95,4 +95,4 @@
9595
],
9696
"recursive": true
9797
}
98-
}
98+
}

src/types.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ export type {
9494
} from "fastify";
9595
/* eslint-enable max-len */
9696

97-
export type ServerInfo = {
98-
address: string;
99-
port: number;
100-
};
97+
export type ServerInfo = { address: string; port: number };
10198

10299
export interface ElectrodeFastifyInstance extends FastifyInstance {
103100
info: ServerInfo;
@@ -204,7 +201,27 @@ export type ElectrodeServerConfig = {
204201
* ```
205202
*/
206203
plugins?: PluginsConfig;
207-
/** options to be passed to fastify verbatim */
204+
/**
205+
* options to be passed to fastify verbatim
206+
*
207+
* **Note for Fastify 5 migration:**
208+
* - `requestIdHeader` now defaults to `false` instead of `"request-id"`
209+
* - Router options like `maxParamLength`, `ignoreTrailingSlash`, etc. should be
210+
* moved under `routerOptions` to avoid deprecation warnings
211+
* - Example:
212+
* ```js
213+
* {
214+
* server: {
215+
* requestIdHeader: false, // explicit default in Fastify 5
216+
* routerOptions: {
217+
* maxParamLength: 1000,
218+
* ignoreTrailingSlash: false,
219+
* caseSensitive: true
220+
* }
221+
* }
222+
* }
223+
* ```
224+
*/
208225
server?: FastifyServerOptions;
209226
/** settings specific to Electrode's add-ons for the fastify server */
210227
electrode?: ElectrodeOptions;

test/sample/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable */
2-
31
"use strict";
42
const fastifyPlugin = require("fastify-plugin");
53
const path = require("path");
@@ -60,4 +58,5 @@ const config = {
6058
});
6159
}
6260
};
63-
require("../../")(config);
61+
const { electrodeServer } = require("../../");
62+
electrodeServer(config);

0 commit comments

Comments
 (0)