-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (42 loc) · 1012 Bytes
/
index.js
File metadata and controls
47 lines (42 loc) · 1012 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
38
39
40
41
42
43
44
45
46
47
/**
* express for creating the server.
*/
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
/**
* body parser
*/
app.use(bodyParser.json());
app.use(bodyParser.text());
app.use(bodyParser.urlencoded({extended : true}));
/**
* setting the configurable data to process.env.
*/
require('./config');
/**
* making the connection with the database.
*/
const mongoose = require('mongoose');
mongoose.connect(process.env.DB_URL);
const database = mongoose.connection;
database.on('error',()=>{
console.log("Some error while connecting to the database.");
})
database.once('open',()=>{
console.log("Successfully connected with the database.");
})
/**
* routes for notifications.
*/
require('./routes/notification.routes')(app);
/**
* attaching the cron file.
*/
require('./schedulers/email.scheduler');
/**
* starting the server.
*/
app.listen(process.env.PORT,()=>{
console.log("server started running at port : ",process.env.PORT);
});