💥 breaking: update endpoint to support new banner schema
All checks were successful
Integration Tests / integration-tests (pull_request) Successful in 1m42s

This commit is contained in:
2026-03-25 12:39:23 +07:00
parent 794a130562
commit 7f6b1373f4
3 changed files with 26 additions and 52 deletions

View File

@ -1,12 +1,12 @@
import { Prisma } from "@prisma/client";
import { AppError } from "../../../helpers/error/instances/app";
import { prisma } from "../../../utils/databases/prisma/connection";
import { generateUUIDv7 } from "../../../helpers/databases/uuidv7";
import { SystemAccountId } from "../../../config/account/system";
import { Static } from "elysia";
import { createHeroBannerSchema } from "../schemas/createHeroBanner.schema";
import { Prisma } from "@prisma/client";
export const insertHeroBannerRepository = async (
payload: Omit<Prisma.HeroBannerCreateInput, "id" | "createdBy">,
) => {
export const insertHeroBannerRepository = async (payload: Static<typeof createHeroBannerSchema.body>) => {
try {
return await prisma.heroBanner.create({
data: {
@ -16,6 +16,9 @@ export const insertHeroBannerRepository = async (
},
});
} catch (error) {
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === "P2002") {
throw new AppError(400, "A hero banner with the order priority already exists", error);
}
throw new AppError(500, "Failed to insert hero banner", error);
}
};