Created the PATCH /project/:id route
This commit is contained in:
@@ -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;
|
Reference in New Issue
Block a user