atsid / express-jefferson

Declarative Application Routing
Apache License 2.0
4 stars 1 forks source link

Add Parameter Resolvers configuration section #11

Closed darthtrevino closed 9 years ago

darthtrevino commented 9 years ago

Let's add a 'parameteResolvers' config section that invokes app.param() http://expressjs.com/4x/api.html#app.param

{
    parameterResolvers: [{
         parameter: "id",
         resolver: (req, res, next, id) => User.findById(id).then((found) => {
             res.foundUser = found;
             next();
         });
    }],
    routes: {
        getUser: {
            method: 'GET'
            path: "/:id",
            middleware: [ // asssume req.foundUser is populated ] 
        }
    }
}