Hooks
Stentor API Reference / stentor-models/src / Hooks
Interface: Hooks
Defined in: packages/stentor-models/src/Runtime/Hooks.ts:12
Hooks are used to provide the opportunity to modify or log runtime data at different points in the lifecycle.
Methodsβ
preExecution()?β
optionalpreExecution(event,context,callback):Promise\<{event:object;context:RuntimeContext;callback:RuntimeCallback; }>
Defined in: packages/stentor-models/src/Runtime/Hooks.ts:24
Once the channel is selected and before the request is translated, the preExecution hook is called.
This can be used for pre-execution modifications or checks. If an error is thrown, it will be caught and returned. If you return undefined, all execution will halt without throwing an error (feel free to call the callback yourself).
Parametersβ
eventβ
object
contextβ
callbackβ
Returnsβ
Promise\<{ event: object; context: RuntimeContext; callback: RuntimeCallback; }>
Promise that either returns undefined to halt execution or the parameters back.
postRequestTranslation()?β
optionalpostRequestTranslation(request):Promise\<Request>
Defined in: packages/stentor-models/src/Runtime/Hooks.ts:38
This hook is called directly after the request is translated for the channel.
This can be an opportunity to modify the request but the request must be returned to continue operation.
Parametersβ
requestβ
The request after it has been translated
Returnsβ
Promise\<Request>
Promise that passes back the request
postContextCreation()?β
optionalpostContextCreation(request,context):Promise\<{request:Request;context:Context; }>
Defined in: packages/stentor-models/src/Runtime/Hooks.ts:45
This hook, if provided is called after the request is translated then immediately after the context is created. This happens immediately before the handler is deteremined.
Parametersβ
requestβ
contextβ
Returnsβ
Promise\<{ request: Request; context: Context; }>
preResponseTranslation()?β
optionalpreResponseTranslation(request,response,storage):Promise\<{request:Request;response:AbstractResponseBuilder;storage:Storage; }>
Defined in: packages/stentor-models/src/Runtime/Hooks.ts:55
This hook is called before the response is translated for the channel.
Last chance to tweak the platform independent response or collect some data from the request/response (transcript).
Parametersβ
requestβ
responseβ
storageβ
Returnsβ
Promise\<{ request: Request; response: AbstractResponseBuilder; storage: Storage; }>