Routing
File-based Routing
export default async function Route (instance: FastifyInstance) {
instance.get('/api/v1/account', handler);
async function handler(request, reply) {
console.log(request);
reply.status(204);
}
}instance.get('/api/v1/account', handler);
instance.post('/api/v1/account', handler);
instance.patch('/api/v1/account', handler);
instance.head('/api/v1/account', handler);
instance.put('/api/v1/account', handler);
instance.delete('/api/v1/account', handler);
instance.options('/api/v1/account', handler);
instance.any('/api/v1/account', handler);
// you can add fastify route options as well
instance.get('/api/v1/account', fastifyRouteOptions, handler);Built-in Routes
Protecting Routes
Cookie
instance.authenticated()
instance.authenticated()request.account
request.account request.org
request.orgRequest Context
Using API Keys
instance.authorized()
instance.authorized()Changelog
Last updated