-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
38 lines (28 loc) · 901 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
35
36
37
38
const functions = require("firebase-functions");
let dotenv = require("dotenv");
//config dotenv
dotenv.config({ path: "Config/config.env" });
let app = require("./app");
//const firebase = require("firebase");
//connect to database
//server at port
exports.app =functions.https.onRequest(app)
const server = app.listen(process.env.PORT, () => {
console.log(`server is running at port:${process.env.PORT}`);
});
//Handling uncaught Exception
process.on("uncaughtException", (err) => {
console.log(`Error:${err.message}`);
console.log("shutting down server due to uncaught ecxeption");
server.close(() => {
process.exit(1);
});
});
//unhandeled promise Rejection
process.on("unhandledRejection", (err) => {
console.log(`Error:${err.message}`);
console.log(`shutting down the server due to unhandled promise Rejection`);
server.close(() => {
process.exit(1);
});
});