forked from subhransusekhar123/grooso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (29 loc) · 857 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
require("dotenv").config('./.env');
const cookieParser = require('cookie-parser');
const express = require('express');
const cors = require('cors');
const app = express();
const todoRouter = require('./routes/todo.routes');
const userRouter = require('./routes/user.routes');
const connectDb = require('./db/mongoDb');
const port = process.env.SERVER_PORT || 3001
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use(cookieParser());
//corss Origin Resource Sharing
app.use(cors());
//this is for router
app.use("/todo", todoRouter);
app.use('/user',userRouter);
app.get('/', (req, res) => {
res.send('Hello world!!');
})
connectDb()
.then(() => {
app.listen(port, () => {
console.log(`server listening at ${port}`)
})
})
.catch((err) => {
console.error(err)
})