From 870c977a143ae1175e3da1b7baedcc53ac14e3e6 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Wed, 4 Dec 2024 11:14:32 +0000 Subject: [PATCH 1/3] fix(types/index): correct `decorateReply` type Signed-off-by: Frazer Smith --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index c3258f1..25e049a 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -109,7 +109,7 @@ type FastifyAccepts = FastifyPluginCallback Date: Wed, 4 Dec 2024 11:39:00 +0000 Subject: [PATCH 2/3] test(types/index): add tsd tests --- types/index.test-d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/index.test-d.ts b/types/index.test-d.ts index 81dfc0c..a7bc7bf 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -4,6 +4,8 @@ import accepts from '..' const app = fastify() app.register(accepts) +app.register(accepts, { decorateReply: true }) +app.register(accepts, { decorateReply: false }) app.get('/', (request, reply) => { const accept = request.accepts() From 43d355163513c0e237fa239b6d22d41670e42d57 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Wed, 4 Dec 2024 11:39:52 +0000 Subject: [PATCH 3/3] fix(index): check `options.decorateReply` is a boolean --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 89ee821..6b53b6c 100644 --- a/index.js +++ b/index.js @@ -38,7 +38,7 @@ function fastifyAccepts (fastify, options, done) { }) }) - if (options.decorateReply) { + if (options.decorateReply === true) { fastify.decorateReply('requestAccepts', replyAcceptMethod) methodNames.forEach(methodName => {