-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (25 loc) · 1.07 KB
/
index.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
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
var cors = require('cors')
const campaigns = require('./api/routes/campaigns.routes');
const avertiser = require('./api/routes/avertiser.routes');
const swaggerUi = require('swagger-ui-express')
const swaggerFile = require('./swagger_output.json')
const app = express();
app.use('/documentation', swaggerUi.serve, swaggerUi.setup(swaggerFile))
let url = 'mongodb+srv://juninhowerner31:[email protected]/?retryWrites=true&w=majority';
let mongoDB = url;
mongoose.connect(mongoDB);
mongoose.Promise = global.Promise;
let db = mongoose.connection;
db.on('error', console.error.bind(console, 'Erro na Ligação ao MongoDB'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cors())
app.use('/v1/campaigns', campaigns);
app.use('/v1/avertiser', avertiser);
const PORT = process.env.PORT || 5000
app.listen(PORT,"0.0.0.0", () => {
console.log('Servidor em execução na porta' + PORT);
});