Skip to content

Commit

Permalink
Move src/routes.js to src/api/index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohaz committed Oct 27, 2016
1 parent 04dacbc commit a8de026
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
6 changes: 2 additions & 4 deletions generators/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ module.exports = yeoman.Base.extend({

writing: function () {
var props = this.props;
var routesFile = path.join(props.srcDir, 'routes.js');
var routesFile = path.join(props.dir, 'index.js');
var copyTpl = this.fs.copyTpl.bind(this.fs);
var tPath = this.templatePath.bind(this);
var dPath = this.destinationPath.bind(this);
Expand All @@ -183,9 +183,7 @@ module.exports = yeoman.Base.extend({
return statement.type === 'ImportDeclaration';
});
var actualImportCode = recast.print(body[lastImportIndex]).code;
var importString = [
'import ', props.camel, ' from \'./', props.apiDir, '/', props.kebab, '\''
].join('');
var importString = ['import ', props.camel, ' from \'./', props.kebab, '\''].join('');
body.splice(lastImportIndex, 1, importString);
body.splice(lastImportIndex, 0, actualImportCode);

Expand Down
1 change: 1 addition & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ module.exports = yeoman.Base.extend({
copyTpl(tPath('src'), dPath(props.srcDir), props);
copyTpl(tPath('test'), dPath('test'), props);
copyTpl(tPath('services/response'), dPath(props.srcDir + '/services/response'), props);
copyTpl(tPath('api/index.js'), dPath(props.srcDir + '/' + props.apiDir + '/index.js'), props);

if (props.generateAuthApi) {
copyTpl(tPath('services/passport'), dPath(props.srcDir + '/services/passport'), props);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Router } from 'express'
<%_ if (generateAuthApi) { _%>
import user from './<%= apiDir %>/user'
import auth from './<%= apiDir %>/auth'
import user from './user'
import auth from './auth'
<%_ } _%>
<%_ if (typeof passwordReset !== 'undefined' && passwordReset) { _%>
import passwordReset from './<%= apiDir %>/password-reset'
import passwordReset from './password-reset'
<%_ } _%>

const router = new Router()
Expand Down
4 changes: 2 additions & 2 deletions generators/app/templates/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import http from 'http'
import { env, mongo, port, ip } from './config'
import mongoose from './config/mongoose'
import express from './config/express'
import routes from './routes'
import api from './api'

const app = express(routes)
const app = express(api)
const server = http.createServer(app)

mongoose.connect(mongo.uri)
Expand Down

0 comments on commit a8de026

Please sign in to comment.