2016-04-21 14:52:00 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Node.js core.
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a core API
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = {
|
2016-08-09 12:38:05 +02:00
|
|
|
templatesDirectory: scope => {
|
|
|
|
try {
|
|
|
|
// Try to reach the path. If it fail, throw an error.
|
|
|
|
fs.accessSync(path.resolve(__dirname, '..', 'templates', scope.args[1]), fs.constants.R_OK | fs.constants.W_OK);
|
|
|
|
|
|
|
|
return path.resolve(__dirname, '..', 'templates', scope.args[1]);
|
|
|
|
} catch (e) {
|
|
|
|
// Default template is Mongoose
|
|
|
|
return path.resolve(__dirname, '..', 'templates', 'mongoose');
|
|
|
|
}
|
|
|
|
},
|
2016-04-21 14:52:00 +02:00
|
|
|
before: require('./before'),
|
|
|
|
targets: {
|
2016-08-10 11:00:56 +02:00
|
|
|
'api/:humanizeId/controllers/:filename': {
|
2016-04-21 14:52:00 +02:00
|
|
|
template: 'controller.template'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|