-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (26 loc) · 1.01 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
'use strict';
var express = require('express'),
bodyParser = require('body-parser'),
http = require('http'),
config = require('./Config'),
server = express(),
mongoose = require('mongoose'),
CarroInfo = require('./API/Models/CarroInfo'),
TeamInfo = require('./API/Models/TeamInfo'), // criando os modelos aqui
GameSchedule = require('./API/Models/GameSchedule');
// instancia da url de conexão mongoose
mongoose.Promise = global.Promise;
mongoose.connect(config.dbUrl, { useNewUrlParser: true }).then(
(res) => {
console.log("Conectado ao banco de dados com sucesso.")
}
).catch(() => {
console.log("A conexão com o banco de dados falhou.");
});
server.use(bodyParser.urlencoded({ extended: true }));
server.use(bodyParser.json());
var routes = require('./API/Routes/Router'); //importando a rota
routes(server); // registrando a rota
server.listen((process.env.PORT || 8000), function () {
console.log("Servidor está UP e respondendo na porta " + process.env.PORT);
});