-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
42 lines (31 loc) · 1.15 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
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var routes = require('./routes');
var paginate = require('express-paginate');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(methodOverride('X-HTTP-Method'));
app.use(methodOverride('X-HTTP-Method-Override'));
app.use(methodOverride('X-Method-Override'));
app.use(methodOverride('_method'));
app.all('*', function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
});
app.use(express.static('public/dest'));
app.use(express.static('public/upload'));
process.on('uncaughtException', function (err) {
console.log(err);
})
//Sempre todas as confi antes de chamar as rotas se não, não vai funcionar
app.use('/', routes);
var server = app.listen(5000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('http://localhost', host, port);
});
module.exports = app;