-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (28 loc) · 925 Bytes
/
index.js
File metadata and controls
37 lines (28 loc) · 925 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
37
const express=require('express');
const bodyParser = require('body-parser');
const env=require('dotenv');
const mongoose=require('mongoose');
env.config();
const TicketRoutes=require('./routes/ticket.routes');
const Cron=require('./crons/cron');
const app=express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
TicketRoutes(app);
app.get('/',(req,res)=>{
res.send('Home page for notification service');
});
app.listen(process.env.PORT,async()=>{
console.log(`Notification server started at ${process.env.PORT}`);
try{
if(process.env.NODE_ENV=='production'){
await mongoose.connect(process.env.PROD_DB_URL);
}else{
await mongoose.connect(process.env.DB_URL);
}
console.log("Successfully connected to mongo")
}catch(err){
console.log("No connect made with mongo",err);
}
Cron.mailerCron();
});