diff --git a/api/src/controllers/workshopController.ts b/api/src/controllers/workshopController.ts index 8041c49..106955f 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 a05acd7..9fd6946 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,18 +38,18 @@ 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); }, @@ -57,7 +57,7 @@ router.get( // 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); },