Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
this.config.set('registerRoutesFile', 'server/routes.js');
this.config.set('routesNeedle', '// Insert routes below');

this.config.set('routesBase', '/api/');
this.config.set('pluralizeRoutes', true);

this.config.set('insertSockets', true);
this.config.set('registerSocketsFile', 'server/config/socketio.js');
this.config.set('socketsNeedle', '// Insert sockets below');
Expand Down Expand Up @@ -250,4 +253,4 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
}
});

module.exports = AngularFullstackGenerator;
module.exports = AngularFullstackGenerator;
15 changes: 13 additions & 2 deletions endpoint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ util.inherits(Generator, ScriptBase);
Generator.prototype.askFor = function askFor() {
var done = this.async();
var name = this.name;

var base = this.config.get('routesBase') || '/api/';
if(base.charAt(base.length-1) !== '/') {
base = base + '/';
}

// pluralization defaults to true for backwards compat
if (this.config.get('pluralizeRoutes') !== false) {
name = name + 's';
}

var prompts = [
{
name: 'route',
message: 'What will the url of your endpoint to be?',
default: '/api/' + name + 's'
default: base + name
}
];

Expand Down Expand Up @@ -62,4 +73,4 @@ Generator.prototype.createFiles = function createFiles() {
var dest = this.config.get('endpointDirectory') || 'server/api/' + this.name;
this.sourceRoot(path.join(__dirname, './templates'));
ngUtil.processDirectory(this, '.', dest);
};
};