-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
52 lines (44 loc) · 1.29 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
import express from "express";
import cors from "cors";
import swaggerJsDoc from "swagger-jsdoc";
import swaggerUi from "swagger-ui-express";
import feedRoutes from "./routes/feedRoutes.js";
import uploadRoutes from "./routes/uploadRoutes.js";
import userRoutes from "./routes/userRoutes.js";
import postRoutes from "./routes/postRoute.js";
import fileRoutes from "./routes/fileRoutes.js";
import authRoutes from "./routes/authRoutes.js";
import morgan from "morgan";
const app = express();
app.use(cors());
app.use(morgan("dev"));
const swaggerOptions = {
definition: {
openapi: "3.0.0",
info: {
title: "TuneLink API",
version: "1.0.0",
description: "API Documentation for TuneLink",
},
servers: [
{
url: "http://localhost:3000",
},
],
},
apis: ["./routes/*.js"],
};
const swaggerDocs = swaggerJsDoc(swaggerOptions);
// hook up the routes
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocs));
app.use(express.json());
app.use("/api/feed", feedRoutes);
app.use("/api/upload", uploadRoutes);
app.use("/api/user", userRoutes);
app.use("/api/post", postRoutes);
app.use("/api/files", fileRoutes);
app.use("/auth", authRoutes);
app.get("/health", (req, res) => {
res.status(200).send("Server up and running.");
});
export default app;