Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fastify application hook onClose|Add the fastify onClose application hook|ffoncl
fastify application hook onRoute|Add the fastify onRoute application hook|ffonroute, hookonroute
fastify application hook onRegister|Add the fastify onRegister application hook|ffonregister, hookonregister
fastify add schema|Add a shared JSON schema to fastify|ffaddschema, ffsharedschema, ffjsonschema, ffschema
fastify not found handler|Add the default 404 not found handler|ffnotfound, ff404
<!-- ##TOC-BUILDER-END## -->

## Contribute
Expand Down
20 changes: 20 additions & 0 deletions snippets/snippets-js.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,25 @@
"fastify.addSchema($0)"
],
"description": "Add a shared JSON schema to fastify"
},
"fastify not found handler": {
"scope": "javascript,typescript",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the scope is typescript, don't we need to type request and reply ?

"prefix": [
"ffnotfound",
"ff404"
],
"body": [
"fastify.setNotFoundHandler(function basic404(request, reply) {",
" const { url, method } = request.raw",
" const message = `Route ${method}:${url} not found`",
" request.log.info(message)",
" reply.code(404).send({",
" message,",
" error: 'Not Found',",
" statusCode: 404",
" })",
"})"
],
"description": "Add the default 404 not found handler"
}
}