-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
46 lines (30 loc) · 1.26 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
var express = require('express');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var mongooseAutoIncrement = require('mongoose-auto-increment');
var app = express();
app.use(bodyParser.json());
app.use(express.static(__dirname + '/public'));
app.get(/^(?!\/js|\/css|\/img|\/api).*$/, function(req, res) {
var options = {
root: process.env.PWD + '/public/',
dotfiles: 'deny',
headers: {
'x-timestamp': Date.now(),
'x-sent': true
}
};
res.sendFile('index.html', options);
});
mongoose.connect(process.env.MONGOHQ_URL || "mongodb://heroku:Q4a1X7GUj1wACe6cYFpk7vP-gHSirVfay47t9s_pLnyPrgcriSp17dOxdDAquYtt2SCT5o5lYrLfOll0pGej6g@lennon.mongohq.com:10005/app32120463");
var db = mongoose.connection;
mongooseAutoIncrement.initialize(db);
var contentApi = require('./api/contentApi.js');
var comicApi = require('./api/comicApi.js');
app.use('/api/comic', comicApi.comicRouter);
app.use('/api/content', contentApi.contentRouter);
var server = app.listen(process.env.PORT || 3000, function() {
var host = server.address().address;
var port = server.address().port;
console.log('MinaComic listening at http://%s:%s', host, port);
});