Skip to content

Commit

Permalink
added express, file structure updated
Browse files Browse the repository at this point in the history
  • Loading branch information
jeangougou committed Jun 6, 2016
1 parent df17f66 commit e96f4c1
Show file tree
Hide file tree
Showing 27 changed files with 112 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"directory": "client/components/",
"directory": "public/components/",
"timeout": 20000
}
21 changes: 13 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"private": true,
"dependencies": {
"angular": "1.3.8",
"todomvc-common": "^1.0.1",
"todomvc-app-css": "^1.0.1"
}
}
{
"private": true,
"scripts": {
"start": "node server"
},
"dependencies": {
"ejs": "2.4.2",
"express": "4.13.4",
"mongoose": "4.4.20",
"todomvc-app-css": "^1.0.1",
"todomvc-common": "^1.0.1"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

'use strict';

var express = require('express'),
path = require('path'),
fs = require('fs'),
config = require('./server/config/config'),
mongoose = require('mongoose');

/**
* Main application file
*/

// Default node environment to development
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

// Connect to database
var db = mongoose.connect(config.mongo.uri, config.mongo.options);

var app = express();

// Express settings
require('./server/config/express')(app);

// Routing
require('./server/routes')(app);


// Start server
app.listen(config.port, function () {
console.log('Express server listening on port %d in %s mode', config.port, app.get('env'));
});

// Expose app
exports = module.exports = app;
20 changes: 20 additions & 0 deletions server/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

var rootPath = require('path').normalize(__dirname + '/../..');

/**
* Load environment configuration
*/
module.exports = {
root: rootPath,
env: 'development',
port: process.env.PORT || 3000,
mongo: {
uri: 'mongodb://localhost/todo-dev',
options: {
db: {
safe: true
}
}
}
};
13 changes: 13 additions & 0 deletions server/config/express.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

var express = require('express'),
path = require('path'),
config = require('./config');
/**
* Express configuration
*/
module.exports = function(app) {
app.use(express.static(path.join(config.root, 'public')));
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
};
10 changes: 10 additions & 0 deletions server/controllers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

/**
* Send our single page app
*/
module.exports = {
index : function(req, res) {
res.render('index');
}
};
Empty file added server/controllers/todos.js
Empty file.
14 changes: 14 additions & 0 deletions server/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

let express = require('express');
let router = express.Router();

let index = require('./controllers');

/**
* Application routes
*/
module.exports = function(app) {
// All other routes to use Angular routing to default page
app.get('/', index.index);
};
12 changes: 6 additions & 6 deletions client/index.html → views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ <h1>todos</h1>
</p>
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer>
<script src="js/todomvc-common/base.js"></script>
<script src="components/angular/angular.min.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers/todoCtrl.js"></script>
<script src="js/services/todoStorage.js"></script>
<script src="js/directives/todoFocus.js"></script>
<script src="/js/todomvc-common/base.js"></script>
<script src="/components/angular/angular.min.js"></script>
<script src="/js/app.js"></script>
<script src="/js/controllers/todoCtrl.js"></script>
<script src="/js/services/todoStorage.js"></script>
<script src="/js/directives/todoFocus.js"></script>
</body>
</html>

0 comments on commit e96f4c1

Please sign in to comment.