keithwhor / nodal

API Services Made Easy With Node.js
http://www.nodaljs.com/
MIT License
4.51k stars 209 forks source link

Setting "global" variables from middleware #326

Closed somecallmemike closed 7 years ago

somecallmemike commented 7 years ago

Is it possible to pass an object for use in controllers from a middleware? I created an authorization middleware for protected routes which calls AccessToken.verify, and I would like to pass the accessToken/user data from it's output to the next controller.

keithwhor commented 7 years ago

You should have access to the controller object, and we suggest appending user and accessToken to controller.params :).