Skip to content

Commit b7c0809

Browse files
committed
allow users to change the url of the generated endpoint
1 parent 089686f commit b7c0809

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

endpoint/index.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,30 @@ var Generator = module.exports = function Generator() {
1111

1212
util.inherits(Generator, ScriptBase);
1313

14-
Generator.prototype.registerEndpoint = function() {
14+
Generator.prototype.askFor = function askFor() {
15+
var done = this.async();
16+
var name = this.name;
17+
var prompts = [
18+
{
19+
name: 'route',
20+
message: 'What will the url of your endpoint to be?',
21+
default: '/api/' + name + 's'
22+
}
23+
];
24+
25+
this.prompt(prompts, function (props) {
26+
this.route = props.route;
27+
done();
28+
}.bind(this));
29+
};
30+
31+
Generator.prototype.registerEndpoint = function registerEndpoint() {
1532
if(this.config.get('insertRoutes')) {
1633
var config = {
1734
file: this.config.get('registerRoutesFile'),
1835
needle: this.config.get('routesNeedle'),
1936
splicable: [
20-
"app.use(\'/api/" + this.name + "s\', require(\'./api/" + this.name + "\'));"
37+
"app.use(\'" + this.route +"\', require(\'./api/" + this.name + "\'));"
2138
]
2239
};
2340
ngUtil.rewriteFile(config);

0 commit comments

Comments
 (0)