69 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-03-18 11:12:50 +01:00
'use strict';
/**
* Module dependencies
*/
// Node.js core.
const fs = require('fs');
const path = require('path');
// Public node modules.
const _ = require('lodash');
/**
* Expose main routes of the generated API
*/
module.exports = scope => {
2016-03-18 11:12:50 +01:00
const newRoutes = {
routes: {}
};
newRoutes.routes['GET /' + scope.humanizeId] = {
controller: scope.globalID,
action: 'find',
policies: []
};
2016-03-18 11:12:50 +01:00
newRoutes.routes['GET /' + scope.humanizeId + '/:id'] = {
controller: scope.globalID,
action: 'findOne',
policies: []
};
2016-03-18 11:12:50 +01:00
newRoutes.routes['POST /' + scope.humanizeId] = {
controller: scope.globalID,
action: 'create',
policies: []
};
2016-03-18 11:12:50 +01:00
newRoutes.routes['PUT /' + scope.humanizeId + '/:id'] = {
controller: scope.globalID,
action: 'update',
policies: []
};
2016-03-18 11:12:50 +01:00
newRoutes.routes['DELETE /' + scope.humanizeId + '/:id'] = {
controller: scope.globalID,
action: 'destroy',
policies: []
};
2016-03-18 11:12:50 +01:00
2016-08-16 11:09:06 +02:00
if (scope.template && scope.template !== 'mongoose') {
newRoutes.routes['POST /' + scope.humanizeId + '/:id/relationships/:relation'] = {
controller: scope.globalID,
action: 'createRelation',
policies: []
};
2016-03-18 11:12:50 +01:00
2016-08-16 11:09:06 +02:00
newRoutes.routes['DELETE /' + scope.humanizeId + '/:id/relationships/:relation'] = {
controller: scope.globalID,
action: 'destroyRelation',
policies: []
};
}
2016-03-18 11:12:50 +01:00
return newRoutes;
};