Created the project.ts router
This commit is contained in:
parent
5d8237419f
commit
599f8ec73a
24
src/routes/v1/project.ts
Normal file
24
src/routes/v1/project.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Request, Response, Router } from "express";
|
||||
import { createProject, deleteProject } from "@controller/projects";
|
||||
import { validateSchema } from "@utils/error";
|
||||
import { projectCreationValidation } from "./validations/project";
|
||||
|
||||
const app: Router = Router();
|
||||
|
||||
app.put("/", async (req: Request, res: Response) => {
|
||||
if (validateSchema(res, projectCreationValidation, req.body)) return;
|
||||
|
||||
const creationError = await createProject(req.body.name, String(req.user?._id));
|
||||
if (creationError) return res.json(creationError);
|
||||
|
||||
res.json({ message: "Your project has been successfully created" });
|
||||
});
|
||||
|
||||
app.delete("/:id", async (req: Request, res: Response) => {
|
||||
const deletionError = await deleteProject(req.params.id);
|
||||
if (deletionError) return res.json(deletionError);
|
||||
|
||||
res.json({ message: "The project has been successfully deleted" });
|
||||
});
|
||||
|
||||
export default app;
|
Loading…
x
Reference in New Issue
Block a user