-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
39 lines (31 loc) · 1.1 KB
/
server.js
File metadata and controls
39 lines (31 loc) · 1.1 KB
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
const app = require('./app');
const connectDatabase = require('./config/database');
const cloudinary = require('cloudinary');
// Handle Uncaught Exceptions
process.on('uncaughtException', err => {
console.log(`ERROR: ${err.stack}`);
console.log('Shutting down server due to Uncaught Exception');
process.exit(1);
});
console.log(a);
// Setting up config file
if (process.env.NODE_ENV !== 'PRODUCTION') require('dotenv').config({ path: 'backend/config/config.env' })
// Connecting to database
connectDatabase();
// Setting up cloudinary configuration
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET
})
// Handle unhandled promise rejections
process.on('unhandledRejection', err => {
console.log(`ERROR: ${err.stack}`);
console.log('Shutting down the server due to Unhandled Promise rejection');
server.close(() => {
process.exit(1);
});
});
const server = app.listen(process.env.PORT, () => {
console.log(`Server started on PORT ${process.env.PORT} in ${process.env.NODE_ENV} mode.`);
})