mirror of
https://github.com/gnmyt/LicenseAPI.git
synced 2026-01-10 18:21:47 +00:00
Add /project/:id/leave route
This commit is contained in:
@ -9,6 +9,7 @@ import {
|
||||
} from "@controller/projects";
|
||||
import { sendError, validateSchema } from "@utils/error";
|
||||
import { patchProjectValidation, projectCreationValidation } from "./validations/project";
|
||||
import {leaveProject} from "@controller/member";
|
||||
|
||||
const app: Router = Router();
|
||||
|
||||
@ -39,6 +40,13 @@ app.delete("/:id", async (req: Request, res: Response) => {
|
||||
res.json({ message: "The project has been successfully deleted" });
|
||||
});
|
||||
|
||||
app.post("/:id/leave", async (req: Request, res: Response) => {
|
||||
const leaveError = await leaveProject(String(req.user?._id), req.params.id);
|
||||
if (leaveError) return res.json(leaveError);
|
||||
|
||||
res.json({ message: "You have successfully left the project" });
|
||||
});
|
||||
|
||||
app.patch("/:id", async (req: Request, res: Response) => {
|
||||
if (validateSchema(res, patchProjectValidation, req.body)) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user