-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
50 lines (39 loc) · 1.19 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Module dependencies.
*/
var express = require('express')
, messages = require('express-messages');
var app = module.exports = express.createServer();
// Config
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.dynamicHelpers({
messages: messages
, base: function(){
// return the app's mount-point
// so that urls can adjust. For example
// if you run this example /text/add works
// however if you run the mounting example
// it adjusts to /blog/text/add
return '/' == app.route ? '' : app.route;
}
});
// Middleware
app.configure(function(){
app.use(express.logger('\x1b[33m:method\x1b[0m \x1b[32m:url\x1b[0m :response-time'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({ secret: 'keyboard cat' }));
app.use(app.router);
app.use(express.static(__dirname + '/public'));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
// Routes
require('./routes/site')(app);
require('./routes/text')(app);
require('./routes/user')(app);
if (!module.parent) {
app.listen(3000);
console.log('Express started on port 3000');
}