Open rtablada opened 8 years ago
Technically, I think this is more of a RouteManager
but want to keep the end user :grinning: so...
The module that takes this map and reduces it into middleware to run through express can be named anything really.
This is the es5 version of this I had working in the app built with Driven.
const Router = require('../driven/services/router');
const AppRouter = Router.compose({
map() {
this.namespace('v1', { path: '/api/v1' }, function() {
this.endpoint('auth', function() {
this.action('sign-in');
this.action('sign-out');
this.action('me');
});
this.endpoint('set', function() {
this.action('list');
this.action('single', { path: '/:id' });
this.action('update', { path: '/:id', method: 'PUT' });
this.action('create', { path: '/', method: 'POST' });
});
});
}
});
module.exports = AppRouter;
Ideally route registration would be something like either:
Ember Inspired
Or more Laravel inspired (less magical
this
keyword):