-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the feature has not already been requested
(Similar but not identical to issue #9)
🚀 Feature Proposal
Currently, the Fastify shorthand declarations are limited to:
fastify.get(path, [options], handler)
fastify.head(path, [options], handler)
fastify.post(path, [options], handler)
fastify.put(path, [options], handler)
fastify.delete(path, [options], handler)
fastify.options(path, [options], handler)
fastify.patch(path, [options], handler)
Please add shorthand methods for the other valid route methods:
'SEARCH', 'TRACE', 'PROPFIND', 'PROPPATCH', 'MKCOL', 'COPY', 'MOVE', 'LOCK' and 'UNLOCK'
Motivation
My organization has planned to begin using the search http method and phase out the use of POST for routes that query with a JSON body. We currently use the shorthand declarations and would like to be able to maintain that consistency, as we also are phasing out and migrating from Express.js to Fastify.
Example
const fastify = require('fastify')({ logger: true })
fastify.search('/', async (request, reply) => {
return { found: 'world' }
})
const start = async () => {
try {
await fastify.listen({ port: 3000 })
} catch (err) {
fastify.log.error(err)
process.exit(1)
}
}
start()