From e2bfb3edc467537af5b3bc3ea2d4e7ec04661a3f Mon Sep 17 00:00:00 2001 From: Austin Bray <93416177+AustinBray77@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:20:21 -0400 Subject: [PATCH 1/2] Added routing example for /api/ --- backend/src/api/routing.js | 15 +++++++++++++++ backend/src/index.js | 7 +++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 backend/src/api/routing.js diff --git a/backend/src/api/routing.js b/backend/src/api/routing.js new file mode 100644 index 0000000..4f58423 --- /dev/null +++ b/backend/src/api/routing.js @@ -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 }; diff --git a/backend/src/index.js b/backend/src/index.js index ed9e8c2..31d3a2b 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -1,11 +1,14 @@ const express = require("express"); - +const api = require("./api/routing"); const app = express(); +const port = 3000; 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"); }); From ec427dac208af91258447c6c342360335dfe6ca6 Mon Sep 17 00:00:00 2001 From: Austin Bray <93416177+AustinBray77@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:20:54 -0400 Subject: [PATCH 2/2] Updated git ignore to exlude .env --- backend/.gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/.gitignore b/backend/.gitignore index 40b878d..3ec544c 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -1 +1,2 @@ -node_modules/ \ No newline at end of file +node_modules/ +.env \ No newline at end of file