-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
44 lines (30 loc) · 971 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
41
42
43
44
const express = require("express");
const connectDB = require("./config/db");
const bodyParser = require("body-parser");
const cors = require("cors");
const app = express();
app.use(cors());
// connect Database
connectDB();
// init middleware
app.use(express.json({extended:false}));
app.get("/", (req, res) =>{
res.send("api is running");
})
// for file upload
const fileRoute = require("./middleware/file");
// define routes
const authRouter = require("./routes/api/auth");
const postRouter = require("./routes/api/post");
const profileRouter = require("./routes/api/profile");
const userRouter = require("./routes/api/users");
// app.use("/upload", fileRoute);
app.use("/api/auth", authRouter);
app.use("/api/users", userRouter);
app.use("/api/post", postRouter);
app.use("/api/profile",profileRouter);
const PORT = process.env.PORT || 8800;
[]
app.listen(PORT, () =>{
console.log(`server started on port ${PORT}`)
})