-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (19 loc) · 715 Bytes
/
server.js
File metadata and controls
24 lines (19 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import express from "express";
import cors from "cors";
import swaggerUi from "swagger-ui-express";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const swaggerFile = require("./swagger-output.json");
// Import routes
import articleRoutes from "./src/routes/article.routes.js";
const app = express();
const PORT = 8080;
app.use(cors());
app.use(express.json());
app.use("/api", articleRoutes); // Mount routes under /api base path
// Swagger
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerFile));
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
console.log(`Swagger docs at http://localhost:${PORT}/api-docs`);
});