From 391e3dfd02c3cfd6af3d9b49a1ffe75b041aea62 Mon Sep 17 00:00:00 2001 From: Samuel Thompson Date: Sun, 8 Dec 2024 15:44:12 -0600 Subject: [PATCH] Reformatted --- api/src/controllers/workshopController.ts | 14 ++++++------ api/src/routes/workshop.ts | 26 +++++++++++------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/api/src/controllers/workshopController.ts b/api/src/controllers/workshopController.ts index 106955f..8041c49 100644 --- a/api/src/controllers/workshopController.ts +++ b/api/src/controllers/workshopController.ts @@ -1,7 +1,7 @@ // NO POPULATE VERSION -import { Request, Response } from "express"; -import { Workshop } from "../model/Workshop"; +import { Request, Response } from 'express'; +import { Workshop } from '../model/Workshop'; export const createWorkshop = async (req: Request, res: Response) => { try { @@ -16,7 +16,7 @@ export const createWorkshop = async (req: Request, res: Response) => { const savedWorkshop = await newWorkshop.save(); res.status(201).json(savedWorkshop); } catch (error) { - res.status(500).json({ message: "Error creating workshop", error }); + res.status(500).json({ message: 'Error creating workshop', error }); } }; @@ -27,12 +27,12 @@ export const getWorkshop = async (req: Request, res: Response) => { const workshop = await Workshop.findById(id); if (!workshop) { - return res.status(404).json({ message: "Workshop not found" }); + return res.status(404).json({ message: 'Workshop not found' }); } res.status(200).json(workshop); } catch (error) { - res.status(500).json({ message: "Error retrieving workshop", error }); + res.status(500).json({ message: 'Error retrieving workshop', error }); } }; @@ -47,12 +47,12 @@ export const getWorkshopsByUserId = async (req: Request, res: Response) => { if (workshops.length === 0) { return res .status(404) - .json({ message: "No workshops found for this user" }); + .json({ message: 'No workshops found for this user' }); } res.status(200).json(workshops); } catch (error) { - res.status(500).json({ message: "Error retrieving workshops", error }); + res.status(500).json({ message: 'Error retrieving workshops', error }); } }; diff --git a/api/src/routes/workshop.ts b/api/src/routes/workshop.ts index 1e0014f..a05acd7 100644 --- a/api/src/routes/workshop.ts +++ b/api/src/routes/workshop.ts @@ -1,12 +1,12 @@ -import express from "express"; -import mongoose from "mongoose"; -import dbConnect from "../config/db"; // Import the dbConnect function +import express from 'express'; +import mongoose from 'mongoose'; +import dbConnect from '../config/db'; // Import the dbConnect function import { createWorkshop, getWorkshop, getWorkshopsByUserId, -} from "../controllers/workshopController"; +} from '../controllers/workshopController'; const router = express.Router(); @@ -19,14 +19,14 @@ const workshopIDSchema = new mongoose.Schema({ s3ID: String, }); -const Workshop = mongoose.model("WorkshopID", workshopIDSchema); +const Workshop = mongoose.model('WorkshopID', workshopIDSchema); // Route to create a new workshop -router.post("/create-workshop", async (req: any, res: any) => { +router.post('/create-workshop', async (req: any, res: any) => { const { name, s3id } = req.body; if (!name || !s3id) { - return res.status(400).json({ message: "Missing required fields" }); + return res.status(400).json({ message: 'Missing required fields' }); } // Create a new workshop @@ -38,29 +38,29 @@ router.post("/create-workshop", async (req: any, res: any) => { try { const savedWorkshop = await newWorkshop.save(); res.status(201).json({ - message: "Workshop created successfully", + message: 'Workshop created successfully', WorkshopID: savedWorkshop, }); } catch (error) { - res.status(401).json({ message: "Failed to create workshop", error }); + res.status(401).json({ message: 'Failed to create workshop', error }); } }); // router.post("/workshops", createWorkshop) // router.get('/workshops/:id', getWorkshop); router.get( - "/workshops/:id", + '/workshops/:id', async (req: express.Request, res: express.Response) => { await getWorkshop(req, res); - } + }, ); // Route to get workshops by user ID router.get( - "/workshops/user/:userId", + '/workshops/user/:userId', async (req: express.Request, res: express.Response) => { await getWorkshopsByUserId(req, res); - } + }, ); // POPULATE VERSION (if details of mentor/mentee objects are needed on the frontend like name or picture)