adding the order service delete on the plan api

This commit is contained in:
2026-04-26 18:57:33 +06:00
parent 4c1614601a
commit 107b94bc97
6 changed files with 17 additions and 7 deletions
+4
View File
@@ -161,6 +161,10 @@ const update_order_into_db = async (req: Request) => {
const delete_order_from_db = async (req: Request) => {
// define your own login here
const { id } = req.params as { id: string };
const user = req.user;
if (user?.role !== "ADMIN") {
throw new AppError("You are not authorized to perform this action", 403);
}
const result = await prisma.order.delete({ where: { id } });
return result;
};
+6 -2
View File
@@ -3,7 +3,11 @@ export const orderSwaggerDocs = {
post: {
tags: ["order"],
summary: "Create new order",
description: "",
description: ` INITIATED
CONFIRMED
ONGOING
DELIVERED
CANCELLED`,
requestBody: {
required: true,
content: {
@@ -116,7 +120,7 @@ export const orderSwaggerDocs = {
},
patch: {
tags: ["order"],
summary: "Update order",
summary: "Update order -(Admin route)",
description: "",
parameters: [
{
+3 -3
View File
@@ -1,5 +1,5 @@
import { Router } from "express";
import { Router } from "express";
import auth from "../../middlewares/auth";
import RequestValidator from "../../middlewares/request_validator";
import { plan_controller } from "./plan.controller";
import { plan_validations } from "./plan.validation";
@@ -10,6 +10,7 @@ router.get("/", plan_controller.get_all_plan);
router.post(
"/",
RequestValidator(plan_validations.create_plan),
auth("ADMIN"),
plan_controller.create_plan,
);
router.get("/:id", plan_controller.get_single_plan);
@@ -21,4 +22,3 @@ router.patch(
router.delete("/:id", plan_controller.delete_plan);
export default router;
+1 -1
View File
@@ -22,7 +22,7 @@ const get_single_plan_from_db = async (req: Request) => {
const create_plan_into_db = async (req: Request) => {
// define your own login here
const user = req.user
const user = req?.user
if (user?.role !== "ADMIN") {
throw new AppError("You dont have permission to create plan information.!!!", 401)
}
@@ -7,6 +7,7 @@ const update_profile_into_db = async (req: Request) => {
const user = req?.user as JwtPayloadType;
const payload = req?.body;
const file = req?.file;
console.log(payload);
// check file and upload to cloud
if (file) {
const cloudRes = await uploadCloud(file);