Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fahrtenbuch
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWP WS21_22 - Fahrtenbuch
Team Einhorn
fahrtenbuch
Commits
61043852
Commit
61043852
authored
3 years ago
by
fu6454io
Browse files
Options
Downloads
Patches
Plain Diff
create sport controllers
parent
2355b226
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/src/controllers/sport.controllers.ts
+61
-0
61 additions, 0 deletions
server/src/controllers/sport.controllers.ts
with
61 additions
and
0 deletions
server/src/controllers/sport.controllers.ts
0 → 100644
+
61
−
0
View file @
61043852
/*import { Request, Response } from "express";
import sport from "../db/models/Sport";
import Boat from "../db/models/Boat";
import BoatType from "../db/models/BoatType";
//createSportController
const createSportController = async (req: Request, res: Response) => {
try {
if (!(res.locals.user.role == "coordinator")) {
return res
.status(403)
.json({ success: false, error: "MustBeCoordinator" });
}
const newSportInput = req.body;
const newSport = await sport.create(newSportInput);
if (newSport) {
return res.status(201).json({
success: true,
result: {
id: newSport.id,
name: newSport.name,
},
});
}
} catch (error) {
console.error(error.message);
return res.status(500).json({ success: false, error: "serverError" });
}
};
//show all Sports
const showAllSports = async (req: Request, res: Response) => {
try {
if (!(res.locals.user.role === "coordinator")) {
return res
.status(403)
.json({ success: false, error: "MustBeCoordinator" });
}
const allSports = await sport.findAll();
return res.status(200).send({
success: true,
result: allSports.map((sport) => {
return { id: sport.id, name: sport.name };
}),
});
} catch (error) {
console.error("server error: ", error.message);
return res.status(500).json({ success: false, error: "serverError" });
}
};
const sportControllers = {
createSportController,
showAllSports
};
export default sportControllers;
*/
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment