forked from stirthraj/electricity-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (27 loc) · 738 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
const express = require('express');
const cors = require('cors');
var cookieParser = require('cookie-parser');
const mongoose = require('mongoose');
const app = express();
app.use(
cors({
origin: 'http://localhost:3000',
credentials: true,
})
);
app.use(cookieParser());
const MONGODB_URI = '';
app.use(express.json());
const PORT = 3001;
app.listen(PORT, () => console.log('Server is active on port ' + PORT));
mongoose.Promise = Promise;
mongoose.connect(
MONGODB_URI,
{ useNewUrlParser: true, useUnifiedTopology: true },
(err) => {
if (err) return console.log(err);
console.log('mongodb connection established');
}
);
app.options('*', cors());
app.use('/electric', require('./src/routes/prevmonthbill'));