Skip to content

Commit

Permalink
ref: remove token validation from backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyton505 committed Nov 11, 2024
1 parent ce7feb1 commit ad79fc7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
15 changes: 11 additions & 4 deletions api/src/routes/user.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import express from "express";
import mongoose from "mongoose";
import dbConnect from "../config/db";
import { validateAccessToken } from "../controllers/auth0-middleware";
// import { validateAccessToken } from "../controllers/auth0-middleware";

const router = express.Router();

router.use(validateAccessToken);
// TODO: Add auth0 middleware
// router.use(validateAccessToken);

// Call the dbConnect function to connect to MongoDB
dbConnect();
Expand Down Expand Up @@ -69,9 +70,15 @@ router.post("/create-user", async (req: any, res: any) => {
// Test route to check if the API is working
router.post("/test", async (req: any, res: any) => {
console.log("Received group data:");
const { name } = req.body;

return res.status(200).json({ name });
let name;
if (req.body.name === undefined) {
name = "empty";
} else {
({ name } = req.body);
}

return res.status(200).json(`Your name is ${name}`);
});

export default router;
7 changes: 4 additions & 3 deletions api/src/routes/workshop.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import express from "express";
import mongoose from "mongoose";
import dbConnect from "../config/db"; // Import the dbConnect function
import { validateAccessToken } from "../controllers/auth0-middleware";
// import { validateAccessToken } from "../controllers/auth0-middleware";

import { createWorkshop, getWorkshop } from "../controllers/workshopController";

const router = express.Router();

router.use(validateAccessToken);
// TODO: Add auth0 middleware
// router.use(validateAccessToken);

// Call the dbConnect function to connect to MongoDB
dbConnect();
Expand Down Expand Up @@ -51,7 +52,7 @@ router.get(
"/workshops/:id",
async (req: express.Request, res: express.Response) => {
await getWorkshop(req, res);
},
}
);

router.post("/testId/:id", async (req: any, res: any) => {
Expand Down
2 changes: 1 addition & 1 deletion api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ app.use(notFoundHandler);
app.use(errorHandler);

app.listen(process.env.PORT || 8000, () =>
console.log(`Server running on port ${process.env.PORT || 8000}`),
console.log(`Server running on port ${process.env.PORT || 8000}`)
);

0 comments on commit ad79fc7

Please sign in to comment.