Request Helpers
Last updated
Was this helpful?
Last updated
Was this helpful?
This is a catalog of available convenience methods available in Novel registered using Fastify's request and reply decorators.
request.account
This includes details on which user is accessing that request.
request.org
This includes details on which organization is being used by the current request
request.account
and request.org
are both and will trigger errors if accessed outside of instance.authorized()
or instance.authenticated()
directives.
await request.can(action: string, subject: any, fields: string[])
Discussed in Authorization
A convenience method that allows you to check if the currently logged in user is allowed to take action
towards the specific subject
.
This uses the CASL can
signature.
await request.cannot(action: string, subject: any, fields: string[])
Discussed in Authorization
This is the inverse of await request.can()
above.
await request.verified()
Check if the currently logged in user has a verified
status.
await request.subscribed()
Check if the currently logged in organization has an active subscription.
request.ua()
A convenience method that exposes an object that has the user-agent parsed by the my-ua-parser
library.
reply.error(error: FastifyError)
A response builder that consolidates errors and produces an error format unique to Novel.
await reply.uncache(key: string, options?: CacheOptions)
This is a decorator to reply that you can use to manually purge a cached response.
2024-12-20 - Initial Documentation
See
Check the.
See