-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
51 lines (44 loc) · 1.13 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const express = require("express");
const app = express();
const userRoutes = require("./routes/User");
const database = require("./config/database");
const cookieParser = require("cookie-parser");
const cors = require("cors");
const {cloudinaryConnect} = require("./config/cloudinary");
const fileUpload = require("express-fileupload");
const dotenv = require("dotenv");
dotenv.config();
const PORT = process.env.PORT || 4000;
//database connect
database.connect();
//middlewares
app.use(express.json());
app.use(cookieParser());
app.use(
cors({
origin:"http:localhost:3000",
credentials:true,
})
)
app.use(
fileUpload({
useTempFiles:true,
tempFileDir:"/tmp",
})
)
//connect to cloudinary
cloudinaryConnect();
app.use("/api/v1/auth",userRoutes);
//file routes
const FileUpload = require("./routes/FileUpload");
app.use("/api/v1",FileUpload);
//default route
app.get("/",(req,res)=>{
return res.json({
success:true,
message:'Your server is up and running...'
});
});
app.listen(PORT,()=>{
console.log(`App running at ${PORT}`)
})