Skip to content

Commit

Permalink
Reformatted again
Browse files Browse the repository at this point in the history
  • Loading branch information
samthomp14 committed Dec 8, 2024
1 parent 391e3df commit fe18203
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
14 changes: 7 additions & 7 deletions api/src/controllers/workshopController.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 });
}
};

Expand All @@ -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 });
}
};

Expand All @@ -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 });
}
};

Expand Down
22 changes: 11 additions & 11 deletions api/src/routes/workshop.ts
Original file line number Diff line number Diff line change
@@ -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();

Expand All @@ -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
Expand All @@ -38,26 +38,26 @@ 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);
},
Expand Down

0 comments on commit fe18203

Please sign in to comment.