Sailsjs - How to get the current request outside the controller
1 answer
NodeJS Domains can do what you are looking for. You can create a middleware / policy that creates a new one domain
for each request and sets the req object as a property in domain
. Then you can just access the property from the object domain
.
However, it looks like a code smell. You might want to look at converting your service to Class
and just create it with req
. Then you can just pass service
to your code.
0
source to share