11'use strict' ;
22
3- /**
4- * Module dependencies.
5- */
6-
3+ // Module dependencies.
74var express = require ( 'express' ) ,
8- http = require ( 'http' ) ,
9- path = require ( 'path' ) ,
10- api = require ( './lib/routes/api' ) ;
5+ path = require ( 'path' ) < % if ( mongo ) { % > ,
6+ fs = require ( 'fs' ) < % } % > ;
117
128var app = express ( ) ;
9+ < % if ( mongo ) { % >
10+ // Connect to database
11+ var db = require ( './lib/db/mongo' ) ;
12+
13+ // Bootstrap models
14+ var modelsPath = path . join ( __dirname , 'lib/models' ) ;
15+ fs . readdirSync ( modelsPath ) . forEach ( function ( file ) {
16+ require ( modelsPath + '/' + file ) ;
17+ } ) ;
1318
14- // Configuration
19+ // Populate empty DB with dummy data
20+ require ( './lib/db/dummydata' ) ;
21+ < % } % >
22+ // Controllers
23+ var api = require ( './lib/controllers/api' ) ;
1524
25+ // Express Configuration
1626app . configure ( function ( ) {
1727 app . use ( express . logger ( 'dev' ) ) ;
1828 app . use ( express . bodyParser ( ) ) ;
@@ -24,20 +34,18 @@ app.configure('development', function(){
2434 app . use ( express . static ( path . join ( __dirname , '.tmp' ) ) ) ;
2535 app . use ( express . static ( path . join ( __dirname , 'app' ) ) ) ;
2636 app . use ( express . errorHandler ( ) ) ;
27- }
37+ } ) ;
2838
2939app . configure ( 'production' , function ( ) {
3040 app . use ( express . favicon ( path . join ( __dirname , 'public/favicon.ico' ) ) ) ;
3141 app . use ( express . static ( path . join ( __dirname , 'public' ) ) ) ;
32- }
42+ } ) ;
3343
3444// Routes
35-
3645app . get ( '/api/awesomeThings' , api . awesomeThings ) ;
3746
3847// Start server
39-
4048var port = process . env . PORT || 3000 ;
4149app . listen ( port , function ( ) {
42- console . log ( 'Express server listening on port %d in %s mode' , app . address ( ) . port , app . get ( 'env' ) ) ;
50+ console . log ( 'Express server listening on port %d in %s mode' , port , app . get ( 'env' ) ) ;
4351} ) ;
0 commit comments