-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (29 loc) · 859 Bytes
/
server.js
File metadata and controls
36 lines (29 loc) · 859 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
35
36
const app = require("./app");
const connectDb = require('./db/Database')
const cloudinary = require("cloudinary");
// handling uncaught Exception
process.on("uncaughtException", (err) => {
console.log(`ERROR: ${err.message}`);
console.log(`Shutting down server`);
});
if (process.env.NODE_ENV !== "PRODUCTION") {
require("dotenv").config({
path: "./.env",
});
}
connectDb()
const server = app.listen(process.env.PORT, () => {
console.log(`Server is running on https://localhost:${process.env.PORT}`);
});
// Unhandle promises
process.on("onhandleRejection", (err) => {
console.log(`Shutting down server for ${err.message}`);
server.close(() => {
process.exit(1);
});
});
cloudinary.config({
cloud_name: process.env.CLOUDINARY_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET
})