-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (28 loc) · 706 Bytes
/
server.js
File metadata and controls
34 lines (28 loc) · 706 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
33
34
const mongoose = require('mongoose');
const dotenv = require('dotenv');
// env configuration
dotenv.config({ path: './.env' });
const app = require('./app');
// DB variable
const DB = process.env.DATABASE.replace(
'<PASSWORD>',
process.env.DATABASE_PASSWORD
);
// DB Connection
mongoose
.connect(DB, {
useUnifiedTopology: true,
useNewUrlParser: true,
})
.then(() => {
console.log(`Database Connection Successful!`);
})
.catch((err) => {
console.log(`Error Connecting...! The Error Is: ${err}`);
});
// server PORT
const PORT = process.env.PORT || 3000;
// start server
app.listen(PORT, () => {
console.log(`Server is running on PORT: ${PORT}`);
});