Skip to content

Type Alias: FastifyHookContext ​

FastifyHookContext = object

What the before hook of fastifyHTTPEntrypoint receives besides the fastify instance: the entrypoint's module, the HTTP server (not listening yet) and the routes the actions will occupy.

Properties ​

actionPrefixes ​

readonly actionPrefixes: string[]

The first segment of each action route ('/device', '/user'…). A route starting with a parameter (/:id) adds none.


isActionPath ​

readonly isActionPath: (requestPath) => boolean

Tell whether a request path belongs to the actions: it equals one of the action prefixes or starts with one followed by /.

Parameters ​

requestPath ​

string

Returns ​

boolean


module ​

readonly module: Module

The module owning the entrypoint, to get the application's objects from (await module.getObject('db')).


routes ​

readonly routes: Map<string, Set<string>>

Each action route mapped to its HTTP methods, in upper case ('/users/:id' → {'GET', 'DELETE'}).


server ​

readonly server: Server

The HTTP server of the fastify instance. It does not listen yet when the hook runs; attach other servers to it there (such as a socket.io server, see the server option of socketIOServiceEntrypoint).

Released under the MIT License.