Skip to content

fix(index): check options.decorateReply is a boolean #178

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Dec 4, 2024
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 index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function fastifyAccepts (fastify, options, done) {
})
})

if (options.decorateReply) {
if (options.decorateReply === true) {
fastify.decorateReply('requestAccepts', replyAcceptMethod)

methodNames.forEach(methodName => {
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type FastifyAccepts = FastifyPluginCallback<fastifyAccepts.FastifyAcceptsOptions

declare namespace fastifyAccepts {
export interface FastifyAcceptsOptions {
decorateReply: boolean
decorateReply?: boolean | undefined
}

export const fastifyAccepts: FastifyAccepts
Expand Down
2 changes: 2 additions & 0 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading