-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (24 loc) · 910 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
import express from "express";
import mongoose from 'mongoose';
import cors from 'cors'
import userRoutes from "./routes/users.js";
import questionRoutes from './routes/Questions.js'
import answerRoutes from './routes/Answer.js'
import dotenv from 'dotenv';
const app = express();
app.use(express.json({ limit: "30mb", extended: true }))
app.use(express.urlencoded({ limit: "30mb", extended: true }))
dotenv.config()
app.use(cors())
app.get('/', (req, res) => {
res.send("This is sample")
})
app.use('/user', userRoutes)
app.use('/questions', questionRoutes)
app.use('/answer', answerRoutes)
const PORT = process.env.PORT || 5000
const CONNECTIONS = process.env.CONNECTION
mongoose.connect(CONNECTIONS, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => app.listen(PORT, () => {
console.log(`sever running on ${PORT}`);
})).catch((err) => console.log(err.message));