-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (25 loc) · 839 Bytes
/
server.js
File metadata and controls
30 lines (25 loc) · 839 Bytes
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
require('dotenv').config();
const http = require('http');
const app = require('./src/app');
const mongoose = require('mongoose');
const port = 3000;
const server = http.createServer(app);
//conection with database MongoDb OBS: To run the database locally comment the ssl: true and sslValidate: false
const options = {
useNewUrlParser: true,
useUnifiedTopology: true,
ssl: true,
sslValidate: false
};
mongoose.connect(process.env.DATABASE_STRING, options);
const db = mongoose.connection;
db.on('error', (err) => console.log(err));
db.once('open', () => console.log('Successfully connected to database online'));
//server
server.listen(port, (err) => {
if (err) {
console.log('No server');
} else {
console.log('Server online url http://localhost:'+`${port}`+'/');
}
});