Created the PATCH /project/:id route
This commit is contained in:
parent
fd907dad2a
commit
d3b5ed8b3b
@ -1,7 +1,7 @@
|
|||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
import { createProject, deleteProject } from "@controller/projects";
|
import { createProject, deleteProject, patchProject } from "@controller/projects";
|
||||||
import { validateSchema } from "@utils/error";
|
import { validateSchema } from "@utils/error";
|
||||||
import { projectCreationValidation } from "./validations/project";
|
import { patchProjectValidation, projectCreationValidation } from "./validations/project";
|
||||||
|
|
||||||
const app: Router = Router();
|
const app: Router = Router();
|
||||||
|
|
||||||
@ -21,4 +21,13 @@ app.delete("/:id", async (req: Request, res: Response) => {
|
|||||||
res.json({ message: "The project has been successfully deleted" });
|
res.json({ message: "The project has been successfully deleted" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.patch("/:id", async (req: Request, res: Response) => {
|
||||||
|
if (validateSchema(res, patchProjectValidation, req.body)) return;
|
||||||
|
|
||||||
|
const patchError = await patchProject(req.params.id, req.body);
|
||||||
|
if (patchError) return res.json(patchError);
|
||||||
|
|
||||||
|
res.json({ message: "The project has been successfully updated" });
|
||||||
|
});
|
||||||
|
|
||||||
export default app;
|
export default app;
|
Loading…
x
Reference in New Issue
Block a user