-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
43 lines (33 loc) · 969 Bytes
/
server.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
35
36
37
38
39
40
41
42
43
const app = require('./app');
const mongoose = require('mongoose')
const dotenv = require('dotenv');
const cloudinary = require('cloudinary')
const port = 3000
dotenv.config({ path: './config.env' });
//DB CONNECT
const DB = process.env.DATABASE.replace(
'<password>',
process.env.DATABASE_PASSWORD
);
// console.log(DB);
mongoose
.connect(DB, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
})
.then(() => console.log('DB connected successfully!!'));
// connect cloudinary cloud storage
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET
})
//SERVER
process.on('uncaughtException', err => {
console.error('err : '+err)
})
app.listen(process.env.PORT || port,() => {
console.log(`app running at port ${port}`)
})