plan_Api: The update api issue was fixed and ready go for testing

This commit is contained in:
Md Sharafat Hassain
2026-04-09 20:55:50 +06:00
parent 75209cc435
commit 2f8c9dbc45
2 changed files with 22 additions and 5 deletions
+4 -1
View File
@@ -33,7 +33,10 @@ const create_plan_into_db = async (req: Request) => {
const update_plan_into_db = async (req: Request) => { const update_plan_into_db = async (req: Request) => {
// define your own login here // define your own login here
const { id } = req.params; const { id } = req.params;
console.log(req.body) const user = req.user
if (user?.role !== "ADMIN") {
throw new AppError("You dont have permission to update plan information.!!!", 401)
}
const isPlanExist = await prisma.plan.findFirst({ const isPlanExist = await prisma.plan.findFirst({
where: { where: {
id: id as string id: id as string
+18 -4
View File
@@ -2,10 +2,10 @@
import { z } from "zod"; import { z } from "zod";
const create_plan = z.object({ const create_plan = z.object({
planName: z.string(), planName: z.string("Enter the plan name..."),
price: z.number(), price: z.number("Enter the plan price..."),
planType: z.enum(["FREE", "STANDARD", "PRO"]), planType: z.enum(["FREE", "STANDARD", "PRO"]),
planDesc: z.string(), planDesc: z.string("Enter the plan description..."),
planFeatures: z.union([ planFeatures: z.union([
z.string(), z.string(),
z.number(), z.number(),
@@ -15,7 +15,21 @@ const create_plan = z.object({
z.record(z.string(), z.any()) z.record(z.string(), z.any())
]) ])
}); });
const update_plan = z.object({}); const update_plan = z.object({
planName: z.string(),
price: z.number(),
planType: z.enum(["FREE", "STANDARD", "PRO"]),
planDesc: z.string().optional(),
planFeatures: z.union([
z.string(),
z.number(),
z.boolean(),
z.null(),
z.array(z.any()),
z.record(z.string(), z.any())
])
});
export const plan_validations = { export const plan_validations = {
create_plan, create_plan,