-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (29 loc) · 937 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
const express=require('express');
const emsRoute = require('./routes/emsRoute');
const userRoute = require('./routes/userRoute');
const mongoose = require('mongoose');
const cors=require("cors");
const categoryRoute = require('./routes/categoryRoute');
const app=express();
app.use(cors());
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use('/user',userRoute);
app.use('/ems',emsRoute);
app.use('/category',categoryRoute)
app.get('/',(req,res)=>{
res.status(200).send("EMS API");
});
//Connection to database
// const PORT=process.env.PORT || 5000;
// mongoose.connect(process.env.MONGO_URL)
mongoose.connect(process.env.MONGO_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(()=>{
app.listen(process.env.PORT || 5000,()=>{
console.log("Server started on port " + (process.env.PORT || 5000));
});
})
.catch((error)=>{
console.log(error)
})
module.exports=app;