Skip to content

Commit 0115450

Browse files
authored
fix(index): check options.decorateReply is a boolean (#178)
* fix(types/index): correct `decorateReply` type Signed-off-by: Frazer Smith <frazer.dev@icloud.com> * test(types/index): add tsd tests * fix(index): check `options.decorateReply` is a boolean --------- Signed-off-by: Frazer Smith <frazer.dev@icloud.com>
1 parent b2018a8 commit 0115450

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function fastifyAccepts (fastify, options, done) {
3838
})
3939
})
4040

41-
if (options.decorateReply) {
41+
if (options.decorateReply === true) {
4242
fastify.decorateReply('requestAccepts', replyAcceptMethod)
4343

4444
methodNames.forEach(methodName => {

types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ type FastifyAccepts = FastifyPluginCallback<fastifyAccepts.FastifyAcceptsOptions
109109

110110
declare namespace fastifyAccepts {
111111
export interface FastifyAcceptsOptions {
112-
decorateReply: boolean
112+
decorateReply?: boolean | undefined
113113
}
114114

115115
export const fastifyAccepts: FastifyAccepts

types/index.test-d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import accepts from '..'
44
const app = fastify()
55

66
app.register(accepts)
7+
app.register(accepts, { decorateReply: true })
8+
app.register(accepts, { decorateReply: false })
79

810
app.get('/', (request, reply) => {
911
const accept = request.accepts()

0 commit comments

Comments
 (0)