Hooks
Appolo Hooks allows you to add custom middleware request lifecycle
Lifecycle#
OnRequest- request initialized with query parse and paramsPreMiddleware- run global middlewares and action middlewaresPreHandler- run controller actiononSend- prepare send response (gzip,headers...)onResponse- send response and headers
Usage#
App#
hooks defined using the app addHook method
Routes#
hooks can be added on routes using the hook decorator
Hooks#
OnRequest#
Called on incoming request
in file config/middlewares/all.ts
PreMiddleware#
Called pre route middleware and after app middleware
in file config/middlewares/all.ts
PreHandler#
Called before controller action
in file config/middlewares/all.ts
OnSend#
Called before response returned you can change the payload
in file config/middlewares/all.ts
OnResponse#
Called after response sent
in file config/middlewares/all.ts
OnError#
Called on error and before all app errors
in file config/middlewares/all.ts