forked from chanson/wikibot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
30 lines (23 loc) · 731 Bytes
/
main.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
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var search = require('./routes/search');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', search);
// catch error and forward to handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handler
app.use(function(err, req, res, next) {
res.status(err.status || 500);
console.log("ERROR=================================");
console.log(err.message);
console.log("======================================");
});
module.exports = app;