From 27b66e6d345a5d02c09f2a9d383947c2ad1539a9 Mon Sep 17 00:00:00 2001 From: Rafi Arrafif Date: Mon, 16 Mar 2026 22:45:13 +0700 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20db:=20update=20sche?= =?UTF-8?q?ma=20to=20match=20new=20banner=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/schema.prisma | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a19bb18..f91c2c2 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -49,6 +49,7 @@ model Media { createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt + bannerPromotion HeroBanner[] @relation("MediaBannerPromotion") logs MediaLog[] @relation("MediaLogs") episodes Episode[] @relation("MediaEpisodes") collections Collection[] @relation("MediaCollections") @@ -557,12 +558,8 @@ model EmailSystemHistory { model HeroBanner { id String @id @db.Uuid orderPriority Int? @unique - isClickable Boolean @default(false) - title String? @db.VarChar(225) - tags String[] - description String? @db.Text - buttonContent String? @db.VarChar(100) - buttonLink String? @db.Text + mediaId String @db.Uuid + media Media @relation("MediaBannerPromotion", fields: [mediaId], references: [id]) imageUrl String? @db.Text startDate DateTime endDate DateTime From 6599fa8f79d7a15f28abe4cffa61862de1b6e2ac Mon Sep 17 00:00:00 2001 From: Rafi Arrafif Date: Tue, 17 Mar 2026 16:41:29 +0700 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20db:=20reset=20prism?= =?UTF-8?q?a=20migrations=20for=20updated=20banner=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/dbml/schema.dbml | 11 +++--- .../migration.sql | 34 +++++++++++++++++-- .../migration.sql | 17 ---------- .../migration.sql | 2 -- .../migration.sql | 20 ----------- .../migration.sql | 32 ----------------- .../migration.sql | 11 ------ .../migration.sql | 16 --------- .../migration.sql | 2 -- .../migration.sql | 8 ----- .../migration.sql | 23 +++++++++++++ 11 files changed, 60 insertions(+), 116 deletions(-) rename prisma/migrations/{000_baseline => 000_baseline_v1}/migration.sql (96%) delete mode 100644 prisma/migrations/20260220133017_rename_code_to_video_code/migration.sql delete mode 100644 prisma/migrations/20260220155805_add_thumbnail_code_in_video/migration.sql delete mode 100644 prisma/migrations/20260301052432_add_hero_banner/migration.sql delete mode 100644 prisma/migrations/20260301052641_rename_hero_banner/migration.sql delete mode 100644 prisma/migrations/20260302155255_add_order_in_hero_banner/migration.sql delete mode 100644 prisma/migrations/20260302160211_rename_order_column/migration.sql delete mode 100644 prisma/migrations/20260303063458_add_tags_in_hero_banner/migration.sql delete mode 100644 prisma/migrations/20260303101939_make_system_preference_id_unique/migration.sql create mode 100644 prisma/migrations/20260317094013_change_banner_to_media_only/migration.sql diff --git a/prisma/dbml/schema.dbml b/prisma/dbml/schema.dbml index 05bab02..d546b66 100644 --- a/prisma/dbml/schema.dbml +++ b/prisma/dbml/schema.dbml @@ -28,6 +28,7 @@ Table medias { deletedAt DateTime createdAt DateTime [default: `now()`, not null] updatedAt DateTime [default: `now()`, not null] + bannerPromotion hero_banner [not null] logs media_logs [not null] episodes episodes [not null] collections collections [not null] @@ -496,12 +497,8 @@ Table email_system_histories { Table hero_banner { id String [pk] orderPriority Int [unique] - isClickable Boolean [not null, default: false] - title String - tags String[] [not null] - description String - buttonContent String - buttonLink String + mediaId String [not null] + media medias [not null] imageUrl String startDate DateTime [not null] endDate DateTime [not null] @@ -780,6 +777,8 @@ Ref: email_system_accounts.createdBy > users.id Ref: email_system_histories.userRelated > users.id +Ref: hero_banner.mediaId > medias.id + Ref: hero_banner.creatorId > users.id Ref: system_notifications.createdBy > users.id diff --git a/prisma/migrations/000_baseline/migration.sql b/prisma/migrations/000_baseline_v1/migration.sql similarity index 96% rename from prisma/migrations/000_baseline/migration.sql rename to prisma/migrations/000_baseline_v1/migration.sql index bf55f6a..e2ec3d9 100644 --- a/prisma/migrations/000_baseline/migration.sql +++ b/prisma/migrations/000_baseline_v1/migration.sql @@ -206,7 +206,8 @@ CREATE TABLE "videos" ( "id" UUID NOT NULL, "episodeId" UUID NOT NULL, "serviceId" UUID NOT NULL, - "code" VARCHAR(255) NOT NULL, + "videoCode" VARCHAR(255) NOT NULL, + "thumbnailCode" TEXT, "pendingUpload" BOOLEAN NOT NULL DEFAULT true, "uploadedBy" UUID NOT NULL, "deletedAt" TIMESTAMP(3), @@ -497,6 +498,26 @@ CREATE TABLE "email_system_histories" ( CONSTRAINT "email_system_histories_pkey" PRIMARY KEY ("id") ); +-- CreateTable +CREATE TABLE "hero_banner" ( + "id" UUID NOT NULL, + "orderPriority" INTEGER, + "isClickable" BOOLEAN NOT NULL DEFAULT false, + "title" VARCHAR(225), + "tags" TEXT[], + "description" TEXT, + "buttonContent" VARCHAR(100), + "buttonLink" TEXT, + "imageUrl" TEXT, + "startDate" TIMESTAMP(3) NOT NULL, + "endDate" TIMESTAMP(3) NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "creatorId" UUID NOT NULL, + + CONSTRAINT "hero_banner_pkey" PRIMARY KEY ("id") +); + -- CreateTable CREATE TABLE "system_preferences" ( "id" UUID NOT NULL, @@ -629,7 +650,7 @@ CREATE UNIQUE INDEX "lang_va_char_language_vaId_charId_key" ON "lang_va_char"("l CREATE UNIQUE INDEX "episodes_mediaId_episode_key" ON "episodes"("mediaId", "episode"); -- CreateIndex -CREATE UNIQUE INDEX "videos_serviceId_code_key" ON "videos"("serviceId", "code"); +CREATE UNIQUE INDEX "videos_serviceId_videoCode_key" ON "videos"("serviceId", "videoCode"); -- CreateIndex CREATE UNIQUE INDEX "video_services_name_key" ON "video_services"("name"); @@ -664,6 +685,12 @@ CREATE UNIQUE INDEX "email_system_accounts_email_key" ON "email_system_accounts" -- CreateIndex CREATE UNIQUE INDEX "email_system_accounts_username_key" ON "email_system_accounts"("username"); +-- CreateIndex +CREATE UNIQUE INDEX "hero_banner_orderPriority_key" ON "hero_banner"("orderPriority"); + +-- CreateIndex +CREATE UNIQUE INDEX "system_preferences_key_key" ON "system_preferences"("key"); + -- CreateIndex CREATE INDEX "_MediaStudios_B_index" ON "_MediaStudios"("B"); @@ -820,6 +847,9 @@ ALTER TABLE "email_system_accounts" ADD CONSTRAINT "email_system_accounts_create -- AddForeignKey ALTER TABLE "email_system_histories" ADD CONSTRAINT "email_system_histories_userRelated_fkey" FOREIGN KEY ("userRelated") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; +-- AddForeignKey +ALTER TABLE "hero_banner" ADD CONSTRAINT "hero_banner_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + -- AddForeignKey ALTER TABLE "system_notifications" ADD CONSTRAINT "system_notifications_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20260220133017_rename_code_to_video_code/migration.sql b/prisma/migrations/20260220133017_rename_code_to_video_code/migration.sql deleted file mode 100644 index c9c46ac..0000000 --- a/prisma/migrations/20260220133017_rename_code_to_video_code/migration.sql +++ /dev/null @@ -1,17 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `code` on the `videos` table. All the data in the column will be lost. - - A unique constraint covering the columns `[serviceId,videoCode]` on the table `videos` will be added. If there are existing duplicate values, this will fail. - - Added the required column `videoCode` to the `videos` table without a default value. This is not possible if the table is not empty. - -*/ --- DropIndex -DROP INDEX "videos_serviceId_code_key"; - --- AlterTable -ALTER TABLE "videos" RENAME COLUMN "code" TO "videoCode"; - --- CreateIndex -DROP INDEX IF EXISTS "videos_serviceId_code_key"; -CREATE UNIQUE INDEX "videos_serviceId_videoCode_key" ON "videos"("serviceId", "videoCode"); diff --git a/prisma/migrations/20260220155805_add_thumbnail_code_in_video/migration.sql b/prisma/migrations/20260220155805_add_thumbnail_code_in_video/migration.sql deleted file mode 100644 index 83ddf44..0000000 --- a/prisma/migrations/20260220155805_add_thumbnail_code_in_video/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "videos" ADD COLUMN "thumbnailCode" TEXT; diff --git a/prisma/migrations/20260301052432_add_hero_banner/migration.sql b/prisma/migrations/20260301052432_add_hero_banner/migration.sql deleted file mode 100644 index 64de72c..0000000 --- a/prisma/migrations/20260301052432_add_hero_banner/migration.sql +++ /dev/null @@ -1,20 +0,0 @@ --- CreateTable -CREATE TABLE "HeroBanner" ( - "id" UUID NOT NULL, - "isClickable" BOOLEAN NOT NULL DEFAULT false, - "title" VARCHAR(225), - "description" TEXT, - "buttonContent" VARCHAR(100), - "buttonLink" TEXT, - "imageUrl" TEXT, - "startDate" TIMESTAMP(3) NOT NULL, - "endDate" TIMESTAMP(3) NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "creatorId" UUID NOT NULL, - - CONSTRAINT "HeroBanner_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE "HeroBanner" ADD CONSTRAINT "HeroBanner_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20260301052641_rename_hero_banner/migration.sql b/prisma/migrations/20260301052641_rename_hero_banner/migration.sql deleted file mode 100644 index 8fb2907..0000000 --- a/prisma/migrations/20260301052641_rename_hero_banner/migration.sql +++ /dev/null @@ -1,32 +0,0 @@ -/* - Warnings: - - - You are about to drop the `HeroBanner` table. If the table is not empty, all the data it contains will be lost. - -*/ --- DropForeignKey -ALTER TABLE "HeroBanner" DROP CONSTRAINT "HeroBanner_creatorId_fkey"; - --- DropTable -DROP TABLE "HeroBanner"; - --- CreateTable -CREATE TABLE "hero_banner" ( - "id" UUID NOT NULL, - "isClickable" BOOLEAN NOT NULL DEFAULT false, - "title" VARCHAR(225), - "description" TEXT, - "buttonContent" VARCHAR(100), - "buttonLink" TEXT, - "imageUrl" TEXT, - "startDate" TIMESTAMP(3) NOT NULL, - "endDate" TIMESTAMP(3) NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "creatorId" UUID NOT NULL, - - CONSTRAINT "hero_banner_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE "hero_banner" ADD CONSTRAINT "hero_banner_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20260302155255_add_order_in_hero_banner/migration.sql b/prisma/migrations/20260302155255_add_order_in_hero_banner/migration.sql deleted file mode 100644 index 0d0e645..0000000 --- a/prisma/migrations/20260302155255_add_order_in_hero_banner/migration.sql +++ /dev/null @@ -1,11 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[order]` on the table `hero_banner` will be added. If there are existing duplicate values, this will fail. - -*/ --- AlterTable -ALTER TABLE "hero_banner" ADD COLUMN "order" INTEGER; - --- CreateIndex -CREATE UNIQUE INDEX "hero_banner_order_key" ON "hero_banner"("order"); diff --git a/prisma/migrations/20260302160211_rename_order_column/migration.sql b/prisma/migrations/20260302160211_rename_order_column/migration.sql deleted file mode 100644 index 532f842..0000000 --- a/prisma/migrations/20260302160211_rename_order_column/migration.sql +++ /dev/null @@ -1,16 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `order` on the `hero_banner` table. All the data in the column will be lost. - - A unique constraint covering the columns `[orderPriority]` on the table `hero_banner` will be added. If there are existing duplicate values, this will fail. - -*/ --- DropIndex -DROP INDEX "hero_banner_order_key"; - --- AlterTable -ALTER TABLE "hero_banner" DROP COLUMN "order", -ADD COLUMN "orderPriority" INTEGER; - --- CreateIndex -CREATE UNIQUE INDEX "hero_banner_orderPriority_key" ON "hero_banner"("orderPriority"); diff --git a/prisma/migrations/20260303063458_add_tags_in_hero_banner/migration.sql b/prisma/migrations/20260303063458_add_tags_in_hero_banner/migration.sql deleted file mode 100644 index 63764e1..0000000 --- a/prisma/migrations/20260303063458_add_tags_in_hero_banner/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "hero_banner" ADD COLUMN "tags" TEXT[]; diff --git a/prisma/migrations/20260303101939_make_system_preference_id_unique/migration.sql b/prisma/migrations/20260303101939_make_system_preference_id_unique/migration.sql deleted file mode 100644 index f9cb54e..0000000 --- a/prisma/migrations/20260303101939_make_system_preference_id_unique/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[key]` on the table `system_preferences` will be added. If there are existing duplicate values, this will fail. - -*/ --- CreateIndex -CREATE UNIQUE INDEX "system_preferences_key_key" ON "system_preferences"("key"); diff --git a/prisma/migrations/20260317094013_change_banner_to_media_only/migration.sql b/prisma/migrations/20260317094013_change_banner_to_media_only/migration.sql new file mode 100644 index 0000000..612c63e --- /dev/null +++ b/prisma/migrations/20260317094013_change_banner_to_media_only/migration.sql @@ -0,0 +1,23 @@ +/* + Warnings: + + - You are about to drop the column `buttonContent` on the `hero_banner` table. All the data in the column will be lost. + - You are about to drop the column `buttonLink` on the `hero_banner` table. All the data in the column will be lost. + - You are about to drop the column `description` on the `hero_banner` table. All the data in the column will be lost. + - You are about to drop the column `isClickable` on the `hero_banner` table. All the data in the column will be lost. + - You are about to drop the column `tags` on the `hero_banner` table. All the data in the column will be lost. + - You are about to drop the column `title` on the `hero_banner` table. All the data in the column will be lost. + - Added the required column `mediaId` to the `hero_banner` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "hero_banner" DROP COLUMN "buttonContent", +DROP COLUMN "buttonLink", +DROP COLUMN "description", +DROP COLUMN "isClickable", +DROP COLUMN "tags", +DROP COLUMN "title", +ADD COLUMN "mediaId" UUID NOT NULL; + +-- AddForeignKey +ALTER TABLE "hero_banner" ADD CONSTRAINT "hero_banner_mediaId_fkey" FOREIGN KEY ("mediaId") REFERENCES "medias"("id") ON DELETE RESTRICT ON UPDATE CASCADE; From 794a130562ec8f2c5c82143926c891ce159d3fc5 Mon Sep 17 00:00:00 2001 From: Rafi Arrafif Date: Wed, 25 Mar 2026 11:37:06 +0700 Subject: [PATCH 3/4] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20cache=20flush=20m?= =?UTF-8?q?odule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/clearHeroBanner.controller.ts | 8 ++++++++ src/modules/flushCache/index.ts | 4 ++++ .../flushCache/services/clearHeroBanner.service.ts | 12 ++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 src/modules/flushCache/controllers/clearHeroBanner.controller.ts create mode 100644 src/modules/flushCache/index.ts create mode 100644 src/modules/flushCache/services/clearHeroBanner.service.ts diff --git a/src/modules/flushCache/controllers/clearHeroBanner.controller.ts b/src/modules/flushCache/controllers/clearHeroBanner.controller.ts new file mode 100644 index 0000000..a7529a3 --- /dev/null +++ b/src/modules/flushCache/controllers/clearHeroBanner.controller.ts @@ -0,0 +1,8 @@ +import { Context } from "elysia"; +import { returnWriteResponse } from "../../../helpers/callback/httpResponse"; +import { clearHeroBannerService } from "../services/clearHeroBanner.service"; + +export const clearHeroBannerController = async (ctx: { set: Context["set"] }) => { + const cacheCleared = await clearHeroBannerService(); + return returnWriteResponse(ctx.set, 200, "Hero banner cache flushed successfully", cacheCleared); +}; diff --git a/src/modules/flushCache/index.ts b/src/modules/flushCache/index.ts new file mode 100644 index 0000000..0665009 --- /dev/null +++ b/src/modules/flushCache/index.ts @@ -0,0 +1,4 @@ +import Elysia from "elysia"; +import { clearHeroBannerController } from "./controllers/clearHeroBanner.controller"; + +export const flushCacheModule = new Elysia({ prefix: "/flush-cache" }).put("/hero-banner", clearHeroBannerController); diff --git a/src/modules/flushCache/services/clearHeroBanner.service.ts b/src/modules/flushCache/services/clearHeroBanner.service.ts new file mode 100644 index 0000000..d01aadb --- /dev/null +++ b/src/modules/flushCache/services/clearHeroBanner.service.ts @@ -0,0 +1,12 @@ +import { redisKey } from "../../../config/redis/key"; +import { AppError } from "../../../helpers/error/instances/app"; +import { redis } from "../../../utils/databases/redis/connection"; + +export const clearHeroBannerService = async () => { + try { + const cache = await redis.del(redisKey.find((key) => key.name === "HERO_BANNER")?.key || ""); + return cache > 0; // Returns true if cache was cleared, false if it was not found + } catch (error) { + throw new AppError(500, "Failed to clear hero banner cache", error); + } +}; From 7f6b1373f4174c60c45d3d4ca0c1f12d5c917109 Mon Sep 17 00:00:00 2001 From: Rafi Arrafif Date: Wed, 25 Mar 2026 12:39:23 +0700 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=92=A5=20breaking:=20update=20endpoin?= =?UTF-8?q?t=20to=20support=20new=20banner=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../insertHeroBanner.repository.ts | 11 ++-- .../schemas/createHeroBanner.schema.ts | 60 +++++-------------- .../services/http/createHeroBanner.service.ts | 7 +-- 3 files changed, 26 insertions(+), 52 deletions(-) diff --git a/src/modules/internal/repositories/insertHeroBanner.repository.ts b/src/modules/internal/repositories/insertHeroBanner.repository.ts index c6b7d35..6d93541 100644 --- a/src/modules/internal/repositories/insertHeroBanner.repository.ts +++ b/src/modules/internal/repositories/insertHeroBanner.repository.ts @@ -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, -) => { +export const insertHeroBannerRepository = async (payload: Static) => { 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); } }; diff --git a/src/modules/internal/schemas/createHeroBanner.schema.ts b/src/modules/internal/schemas/createHeroBanner.schema.ts index 376bd2a..d9c9363 100644 --- a/src/modules/internal/schemas/createHeroBanner.schema.ts +++ b/src/modules/internal/schemas/createHeroBanner.schema.ts @@ -3,45 +3,18 @@ import { AppRouteSchema } from "../../../helpers/types/AppRouteSchema"; export const createHeroBannerSchema = { body: t.Object({ - isClickable: t.Optional( - t.Boolean({ - description: "Indicates whether the hero banner is clickable", - }), - ), - title: t.Optional( - t.String({ - description: "The title of the hero banner", - }), - ), - tags: t.Array(t.String(), { - description: "An array of tags associated with the hero banner", - }), - description: t.Optional( - t.String({ - description: "A brief description of the hero banner", - }), - ), - buttonContent: t.Optional( - t.String({ - description: "The text content of the button on the hero banner", - }), - ), - buttonLink: t.Optional( - t.String({ - description: "The URL that the button on the hero banner links to", - }), + orderPriority: t.Optional( + t.Number({ description: "The priority order of the hero banner. Lower numbers indicate higher priority." }), ), + mediaId: t.String({ description: "The ID of the media associated with the hero banner" }), imageUrl: t.Optional( t.String({ - description: "The URL of the image used in the hero banner", + description: + "The URL of the image used in the hero banner. If not provided, a thumbnail image of the media will be used.", }), ), - startDate: t.String({ - description: "The start date for the hero banner in ISO 8601 format", - }), - endDate: t.String({ - description: "The end date for the hero banner in ISO 8601 format", - }), + startDate: t.Date({ description: "The start date for the hero banner in ISO 8601 format" }), + endDate: t.Date({ description: "The end date for the hero banner in ISO 8601 format" }), }), detail: { summary: "Create a new hero banner", @@ -64,17 +37,16 @@ export const createHeroBannerSchema = { "The created hero banner object. This field is returned only if the environment is running in development mode.", properties: { id: { type: "string", description: "The ID of the created hero banner" }, - isClickable: { type: "boolean", description: "Indicates whether the hero banner is clickable" }, - title: { type: "string", description: "The title of the hero banner" }, - tags: { - type: "array", - items: { type: "string" }, - description: "An array of tags associated with the hero banner", + orderPriority: { + type: "number", + description: "The priority order of the hero banner. Lower numbers indicate higher priority.", + }, + mediaId: { type: "string", description: "The ID of the media associated with the hero banner" }, + imageUrl: { + type: "string", + description: + "The URL of the image used in the hero banner. If not provided, a thumbnail image of the media will be used.", }, - description: { type: "string", description: "A brief description of the hero banner" }, - buttonContent: { type: "string", description: "The text content of the button on the hero banner" }, - buttonLink: { type: "string", description: "The URL that the button on the hero banner links to" }, - imageUrl: { type: "string", description: "The URL of the image used in the hero banner" }, startDate: { type: "string", format: "date-time", diff --git a/src/modules/internal/services/http/createHeroBanner.service.ts b/src/modules/internal/services/http/createHeroBanner.service.ts index d1a8f2a..045d284 100644 --- a/src/modules/internal/services/http/createHeroBanner.service.ts +++ b/src/modules/internal/services/http/createHeroBanner.service.ts @@ -1,10 +1,9 @@ +import { Static } from "elysia"; import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder"; -import { CreateHeroBannerRequestBody } from "../../controllers/createHeroBanner.controller"; import { insertHeroBannerRepository } from "../../repositories/insertHeroBanner.repository"; +import { createHeroBannerSchema } from "../../schemas/createHeroBanner.schema"; -export const createHeroBannerService = async ( - payload: CreateHeroBannerRequestBody, -) => { +export const createHeroBannerService = async (payload: Static) => { try { return await insertHeroBannerRepository(payload); } catch (error) {