forked from BuildForSDGCohort2/Team-51X-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
46 lines (38 loc) · 1.49 KB
/
server.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
// Imports
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
// const cookieParser = require('cookie-parser');
// const cors = require('cors');
// const upload = require('express-fileupload');
const apiRouter = require('./apiRouter').router;
let PORT = 3001;
// Body Parser configuration
// app.use(upload());
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'));
// app.use(cookieParser());
// allow cors requests from any origin and with credentials
// app.use(cors({ origin: (origin, callback) => callback(null, true), credentials: true }));
// app.use(function(req, res, next) {
// res.header("Access-Control-Allow-Origin", req.headers.origin);
// res.header("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
// res.header("Access-Control-Allow-Methods", "GET,HEAD,POST,PUT,DELETE,OPTIONS");
// res.header("Access-Control-Allow-Credentials", "true");
// next();
// });
// Configure routes
app.use('/api/', apiRouter);
// Launch server
app.get('/', function (req, res) {
res.setHeader('Content-Type', 'text/html');
res.status(200).send('<h1>Bienvenue dans Afya</h1>');
});
// global error handler
// app.use(errorHandler);
app.listen(PORT, () =>
console.log('Server en écoute sur:' + PORT)
);