-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): restructured project for easier configuration
global configurations are now setup from the config/env folder. moved routes out of server js and into its own module
- Loading branch information
Showing
25 changed files
with
158 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
test/temp | ||
test/UpperCaseBug | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
var _ = require('lodash'); | ||
|
||
/** | ||
* Load environment configuration | ||
*/ | ||
module.exports = _.extend( | ||
require('./env/all.js'), | ||
require('./env/' + process.env.NODE_ENV + '.js') || {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,13 @@ var mongoose = require('mongoose'),<% if(mongo && mongoPassportUser) { %> | |
User = mongoose.model('User'),<% } %> | ||
Thing = mongoose.model('Thing'); | ||
|
||
/** | ||
* Populate database with sample application data | ||
*/ | ||
|
||
//Clear old things, then add things in | ||
Thing.find({}).remove(function() { | ||
Thing.create({ | ||
Thing.create({ | ||
name : 'HTML5 Boilerplate', | ||
info : 'HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.', | ||
awesomeness: 10 | ||
|
@@ -26,19 +30,19 @@ Thing.find({}).remove(function() { | |
name : 'MongoDB + Mongoose', | ||
info : 'An excellent document database. Combined with Mongoose to simplify adding validation and business logic.', | ||
awesomeness: 10 | ||
}, function(err) { | ||
}, function() { | ||
console.log('finished populating things'); | ||
} | ||
); | ||
}); | ||
<% if(mongo && mongoPassportUser) { %> | ||
// Clear old users, then add a default user | ||
User.find({}).remove(function() { | ||
User.create({ | ||
User.create({ | ||
name: 'Test User', | ||
email: '[email protected]', | ||
password: 'test' | ||
}, function(err) { | ||
}, function() { | ||
console.log('finished populating users'); | ||
} | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
|
||
var rootPath = path.normalize(__dirname + '/../../..'); | ||
|
||
module.exports = { | ||
root: rootPath, | ||
port: process.env.PORT || 3000<% if (mongo) { %>, | ||
mongo: { | ||
options: { | ||
db: { | ||
safe: true | ||
} | ||
} | ||
}<% } %> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
env: 'development'<% if (mongo) { %>, | ||
mongo: { | ||
uri: 'mongodb://localhost/fullstack-dev' | ||
}<% } %> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
env: 'production'<% if (mongo) { %>, | ||
mongo: { | ||
uri: process.env.MONGOLAB_URI || | ||
process.env.MONGOHQ_URL || | ||
'mongodb://localhost/fullstack' | ||
}<% } %> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
env: 'test'<% if (mongo) { %>, | ||
mongo: { | ||
uri: 'mongodb://localhost/fullstack-test' | ||
}<% } %> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
templates/express/api.js → templates/express/controllers/api.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
templates/express/session.js → templates/express/controllers/session.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0
templates/express/mongo/user.js → templates/express/models/user.js
100755 → 100644
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
var api = require('./controllers/api'), | ||
index = require('./controllers')<% if(mongoPassportUser) { %>, | ||
users = require('./controllers/users'), | ||
session = require('./controllers/session'); | ||
|
||
var middleware = require('./middleware')<% } %>; | ||
|
||
/** | ||
* Application routes | ||
*/ | ||
module.exports = function(app) { | ||
|
||
// Server API Routes | ||
app.get('/api/awesomeThings', api.awesomeThings); | ||
<% if(mongoPassportUser) { %> | ||
app.post('/api/users', users.create); | ||
app.put('/api/users', users.changePassword); | ||
app.get('/api/users/me', users.me); | ||
app.get('/api/users/:id', users.show); | ||
|
||
app.post('/api/session', session.login); | ||
app.del('/api/session', session.logout);<% } %> | ||
|
||
// Default all other routes to use Angular Routing | ||
app.get('/partials/*', index.partials); | ||
app.get('/*',<% if(mongoPassportUser) { %> middleware.setUserCookie,<% } %> index.index); | ||
}; |
Oops, something went wrong.