-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
32 lines (22 loc) · 795 Bytes
/
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
// import express from 'express';
// import cors from 'cors';
//mongodb
require('./backend/config/db');
const app = require('express')();
const port = process.env.PORT || 3000;
const UserRouter = require('./backend/api/User');
// Para aceitar posteriormente dados de form
const bodyParser = require('express').json;
// Enable CORS
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT,DELETE");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
next();
});
// app.use(cors());
app.use(bodyParser());
app.use('/user', UserRouter)
app.listen(port, () => {
console.log(`Servidor rodando na porta ${port}`);
})