2
2
/**
3
3
* Module dependencies.
4
4
*/
5
+ _ = require ( "./vendor/underscore" ) ;
5
6
6
- var express = require ( 'express' ) ;
7
+ var Server = { } ,
8
+ express = require ( 'express' ) ,
9
+ path = require ( "path" ) ,
10
+ sys = require ( "sys" ) ,
11
+ application_root = __dirname ;
12
+
13
+ global . Server = Server ;
14
+ Server . root = application_root ;
15
+ global . app = express . createServer ( ) ;
7
16
8
- var app = module . exports = express . createServer ( ) ;
9
17
10
18
// Configuration
11
19
@@ -15,22 +23,19 @@ require('./vendor/nko')('lyXvQ3xB5YL3dZv0', function(err, res) {
15
23
console . error ( err . stack ) ;
16
24
}
17
25
} ) ;
18
- app . configure ( function ( ) {
19
- app . set ( 'views' , __dirname + '/views' ) ;
20
- app . set ( 'view engine' , 'jade' ) ;
21
- app . use ( express . bodyParser ( ) ) ;
22
- app . use ( express . methodOverride ( ) ) ;
23
- app . use ( app . router ) ;
24
- app . use ( express . static ( __dirname + '/public' ) ) ;
25
- } ) ;
26
26
27
- app . configure ( 'development' , function ( ) {
28
- app . use ( express . errorHandler ( { dumpExceptions : true , showStack : true } ) ) ;
27
+ Server . setup = require ( "./lib/setup.js" ) . setup ( {
28
+ app : app ,
29
+ mongoose : require ( "mongoose" ) ,
30
+ express : express ,
31
+ paths : {
32
+ views : path . join ( application_root , "app" , "views" ) ,
33
+ root : path . join ( application_root , "public" ) ,
34
+ controllers : path . join ( application_root , "app" , "controllers" ) ,
35
+ models : path . join ( application_root , "app" , "models" )
36
+ }
29
37
} ) ;
30
38
31
- app . configure ( 'production' , function ( ) {
32
- app . use ( express . errorHandler ( ) ) ;
33
- } ) ;
34
39
35
40
// Routes
36
41
@@ -40,5 +45,4 @@ app.get('/', function(req, res){
40
45
} ) ;
41
46
} ) ;
42
47
43
- app . listen ( 8080 ) ;
44
48
console . log ( "Express server listening on port %d in %s mode" , app . address ( ) . port , app . settings . env ) ;
0 commit comments