Context
Request context module for appolo build with appolo-context and async_hooks
.
new context will be created for every request
#
Installation#
Optionskey | Description | Type | Default |
---|---|---|---|
id | id of context injector | string | context |
in config/modules/all.ts
#
Usagefirst define your context using the @context
decorator
For the example we will define a middleware to set the context data
Now we can access the context from any class using @inject context
note that the context is uniq for every request and cannot share data between requests
In the controller we will put the middleware and access the manager to get the context name
You can also access the current context from getContext
function