-
Notifications
You must be signed in to change notification settings - Fork 2
/
service.js
32 lines (28 loc) · 1017 Bytes
/
service.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 https = require('https');
const express = require("express");
const mongoose = require("mongoose");
const routes = require("./src/routes/routes");
const cors = require("cors");
const PORT= process.env.PORT || 5000;
const HOST = process.env.HOST || 'localhost';
const api = express();
try {
mongoose.connect(
"mongodb+srv://ssesion:flamengo15@cluster0-xsmns.mongodb.net/UserSession?retryWrites=true&w=majority",
{ useNewUrlParser: true, useUnifiedTopology: true,useCreateIndex:true }
);
} catch (error) {
console.log("Deu erro na conexão do BANCO")
}
// mongoose.connect(
// "mongodb+srv://bodegamix:bodegamix2020@cluster0-xsmns.mongodb.net/BDVENDAS?retryWrites=true&w=majority",
// { useNewUrlParser: true, useUnifiedTopology: true,useCreateIndex:true }
// );
api.use(cors());
api.use(express.static('static'));
api.use(express.json());
api.use(routes);
api.listen(PORT, HOST,() => {
console.log("Http server running on port " + 'http://' + HOST + ':' + PORT);
});
module.exports = api;