-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (25 loc) · 846 Bytes
/
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
29
30
31
32
33
34
// Third party modules
const mongoose = require('mongoose');
const dotenv = require('dotenv');
const cloudinary = require('cloudinary').v2;
// Application modules
const app = require('./app');
dotenv.config();
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET
});
const PORT = process.env.PORT || 8080;
const DB_URI = process.env.DB_URI;
async function runServer() {
try {
await mongoose.connect(DB_URI);
console.log(`Connected to db ${mongoose.connection.db.databaseName}`);
app.listen(PORT, '0.0.0.0', () => console.log(`Server is listening on port ${PORT}...`));
} catch (error) {
console.error(error);
console.error('Can not connect to the db!');
}
}
runServer();