Hooks
Appolo Hooks allows you to add custom middleware request lifecycle
#
LifecycleOnRequest
- 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#
Apphooks defined using the app
addHook
method
#
Routeshooks can be added on routes using the hook
decorator
#
Hooks#
OnRequestCalled on incoming request
in file config/middlewares/all.ts
#
PreMiddlewareCalled pre route middleware and after app middleware
in file config/middlewares/all.ts
#
PreHandlerCalled before controller action
in file config/middlewares/all.ts
#
OnSendCalled before response returned you can change the payload
in file config/middlewares/all.ts
#
OnResponseCalled after response sent
in file config/middlewares/all.ts
#
OnErrorCalled on error and before all app errors
in file config/middlewares/all.ts