-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
39 lines (33 loc) · 1.11 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
var express = require('express');
var app = express();
var path = require('path');
var bodyParser = require('body-parser');
var favicon = require('serve-favicon');
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(require('./middleware/locals'));
app.use(favicon(__dirname + '/src/img/favicon.ico'));
app.use('/assets', express.static(path.join(__dirname, 'assets')));
app.use('/public', express.static(path.join(__dirname, 'public')));
app.use(bodyParser.urlencoded({
extended: true,
limit: '5mb'
}));
// Routes
app.use('/', require('./routes/home'));
app.use('/search', require('./routes/search'));
app.use('/help', require('./routes/help'));
// 404 if we couldn't match a route.
app.use(function(req, res, next) {
res.status(404).render('404');
});
// Catch errors
app.use(function(error, req, res, next){
console.error(error.stack);
res.status(500).render('500');
});
var server = app.listen(process.env.PORT, process.env.IP, function () {
var host = server.address().address;
var port = server.address().port;
console.log('listening at http://%s:%s', host, port);
});