-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (23 loc) · 791 Bytes
/
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
require('dotenv').config();
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const cors = require('cors');
const whiteList = {origin: '0.0.0.0/0'};
const userRouter = require('./routes/userRouter');
const adminRouter = require('./routes/adminRouter')
//mongoose
mongoose.connect(process.env.MONGO_CONNECTION_URL,{ useNewUrlParser: true, useUnifiedTopology: true}, (err)=>{
if(err) {
console.log(err)}
else{
console.log("Mongo Connected")
}
});
app.use('/user', express.json(), userRouter);
//Proteger uma rota para que não seja acessível para todos:
app.use('/admin', express.json(), adminRouter);
app.use(cors(whiteList));
app.listen(process.env.PORT, ()=>{
console.log("Server Running...")
})