-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (30 loc) · 801 Bytes
/
server.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
38
39
40
const express=require("express")
const dotenv=require("dotenv").config()
const app=express()
const cors=require("cors")
const connectDb=require("./connectDb")
const fileUpload=require("express-fileupload")
app.use(express.static('static')) // static dir path
app.use(
fileUpload({
limits: {
fileSize: 10000000,
},
abortOnLimit: true,
})
);
const port=process.env.PORT
// connect to database
connectDb()
const corsOptions ={
origin:'*',
credentials:true,
}
// for getting user data from request object before the call of the router
app.use(express.json())
app.use(cors(corsOptions));
// for routes
app.use("/",require("./routes/linkhub"))
app.listen(port,()=>{
console.log(`Server running on port ${port}`)
})