Skip to content

Commit 05d0fda

Browse files
fix(fastify): address deprecation warning
1 parent 21bd8c3 commit 05d0fda

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

benchmarks/fastify.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
const fastify = require('fastify')();
44
fastify.get('/', async (req, reply) => reply.send('Hello world'));
5-
fastify.listen(3000);
5+
fastify.listen({
6+
port: 3000
7+
});

packages/platform-fastify/adapters/fastify-adapter.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,12 @@ export class FastifyAdapter<
226226
public listen(port: string | number, ...args: any[]): void {
227227
const isFirstArgTypeofFunction = typeof args[0] === 'function';
228228
const callback = isFirstArgTypeofFunction ? args[0] : args[1];
229-
const options = {
229+
let options: Record<string, any> = {
230230
port: +port,
231-
host: isFirstArgTypeofFunction ? undefined : args[0],
232231
};
232+
if (!isFirstArgTypeofFunction) {
233+
options.host = args[0];
234+
}
233235
return this.instance.listen(options, callback);
234236
}
235237

0 commit comments

Comments
 (0)