Updated the project.ts route
This commit is contained in:
parent
19878760cb
commit
7c7abd7c21
@ -7,7 +7,7 @@ import {
|
||||
patchProject,
|
||||
regenerateKey,
|
||||
} from "@controller/projects";
|
||||
import { validateSchema } from "@utils/error";
|
||||
import { sendError, validateSchema } from "@utils/error";
|
||||
import { patchProjectValidation, projectCreationValidation } from "./validations/project";
|
||||
|
||||
const app: Router = Router();
|
||||
@ -42,6 +42,9 @@ app.delete("/:id", async (req: Request, res: Response) => {
|
||||
app.patch("/:id", async (req: Request, res: Response) => {
|
||||
if (validateSchema(res, patchProjectValidation, req.body)) return;
|
||||
|
||||
if (Object.keys(req.body).length === 0)
|
||||
return sendError(res, 400, 4, "You need to provide at least one field to update");
|
||||
|
||||
const patchError = await patchProject(req.params.id, String(req.user?._id), req.body);
|
||||
if (patchError) return res.json(patchError);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user