-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules/ | ||
node_modules/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); |