-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
39 lines (30 loc) · 861 Bytes
/
app.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
const express = require("express");
const app = express();
require("dotenv").config();
const userRoutes = require("./routes/users.routes");
const photoRoutes = require("./routes/photos.routes");
const commentRoutes = require("./routes/comments.routes");
const socmedRoutes = require("./routes/socmed.routes");
const PORT = process.env.PORT || 3000;
app.use(express.json());
app.get("/", async (req, res) => {
return res.status(200)
.json({
message: "Hello World!"
})
})
app.use("/users", userRoutes);
app.use("/photos", photoRoutes);
app.use("/comments", commentRoutes);
app.use("/socialmedias", socmedRoutes);
app.use((err, req, res, next) => {
console.log(err)
return res.status(500)
.json({
message: err.message
})
})
app.listen(PORT, () => {
console.log(`Server start at port ${PORT}`);
});
module.exports = app