-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathapp.js
56 lines (52 loc) · 1.54 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
51
52
53
54
55
56
/**
* NodeBlog APP
*/
require('./public/js/date.format');
var connect = require('connect');
var render = require('connect-render');
var blog = require('./controllers/blog');
var user = require('./controllers/user');
var post = require('./controllers/post');
var comment = require('./controllers/comment');
var tag = require('./controllers/tag');
var config = require('./config');
var utils = require('./lib/utils');
var Store = require('./lib/session_store');
var db = require('./db');
if (!config.view_theme) {
config.view_theme = 'simple';
}
var qsOptions = { limit: 100 };
var app = connect(
connect.static(__dirname + '/public'),
connect.logger(),
connect.cookieParser(),
connect.bodyParser(qsOptions),
connect.session({
secret: config.session_secret,
cookie:{ path: '/', httpOnly: true, maxAge: 24 * 3600000 * 3650 },
store: new Store(config.db_options)
}),
connect.query(qsOptions),
user.oauth_handle,
render({
root: __dirname + '/views/'+config.view_theme,
cache: config.view_cache || false,
helpers: {
config: config,
markdown: utils.markdown,
first_paragraph_markdown: utils.first_paragraph_markdown
}
})
);
app.use('/', connect.router(blog));
app.use('/user', connect.router(user));
app.use('/post', connect.router(post));
app.use('/comment', connect.router(comment));
app.use('/tag', connect.router(tag));
app.use(function(req, res, next) {
res.statusCode = 404;
res.render('404.html');
});
app.listen(config.PORT);
console.log("nodeblog started: http://localhost:" + config.PORT);