Skip to content

Commit

Permalink
setup swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewferr committed Oct 17, 2024
2 parents 0d77a2a + 921dab9 commit 4f6423f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
node_modules/
.env
15 changes: 15 additions & 0 deletions backend/src/api/routing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//Example on how routing might work for different paths
const express = require("express");
const router = express.Router();
const globalPath = "/api";

function index(req, res) {
res.send("We are in the API now!");
}

function generateRoutes(app) {
router.get("/", index);
app.use(globalPath, router);
}

module.exports = { generateRoutes };
9 changes: 6 additions & 3 deletions backend/src/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
const express = require("express");

const { specs, swaggerUi } = require("./swagger");

const express = require("express");
const api = require("./api/routing");
const app = express();
const port = 3000;

app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs));

app.get("/", (req, res) => {
res.send("Hello World");
});

app.listen(3000, () => {
api.generateRoutes(app);

app.listen(port, () => {
console.log("Server is running on port 3000");
});

0 comments on commit 4f6423f

Please sign in to comment.