-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (28 loc) · 788 Bytes
/
server.js
File metadata and controls
32 lines (28 loc) · 788 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
30
31
32
require('dotenv').config();
const app = require('./app');
const mongoose = require('mongoose');
// Setting up environment variable
const PORT = process.env.PORT || 3000;
const HOST = process.env.HOST || 'localhost';
//connect to DATABASE
// const DB = process.env.DATABASE.replace(
// '<PASSWORD>',
// process.env.DATABASE_PASSWORD
// );
const DB = process.env.DATABASE_LOCAL;
mongoose
.connect(DB, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
})
.then(() => console.log('DB connection successful!'));
// Running the server
app.listen(PORT, HOST, (err) => {
if (err) {
console.error('Problem starting the server!');
throw err;
}
console.log(`Server running on https://${HOST}:${PORT}`);
});