📝 docs: finish controller documentation for internal module
All checks were successful
Integration Tests / integration-tests (pull_request) Successful in 51s
All checks were successful
Integration Tests / integration-tests (pull_request) Successful in 51s
This commit is contained in:
@ -5,65 +5,12 @@ import { returnWriteResponse } from "../../../helpers/callback/httpResponse";
|
|||||||
import { bulkInsertVideoSchema } from "../schemas/bulkInsertVideo.schema";
|
import { bulkInsertVideoSchema } from "../schemas/bulkInsertVideo.schema";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function bulkInsertVideoController
|
* Bulk insert videos into the database.
|
||||||
* @description Perform bulk insert of videos for specific episodes of a media. This operation inserts multiple videos associated with different episodes into the database based on the provided data.
|
|
||||||
*
|
*
|
||||||
* @param {Context & { body: BulkInsertVideoBodyRequest }} ctx
|
* This controller handles the bulk insertion of videos by accepting an array of video data in the request body,
|
||||||
* The context object containing the request body.
|
* invoking the service to perform the insertion, and returning a response with the inserted video details.
|
||||||
* The body must include:
|
|
||||||
* - media_id: string - The ID of the media for which episodes will be inserted.
|
|
||||||
* - data: Array - An array of episode data, each containing:
|
|
||||||
* - episode: number - The episode number.
|
|
||||||
* - videos: Array - An array of video data for the episode, each containing:
|
|
||||||
* - service_id: string - The ID of the video service.
|
|
||||||
* - code: string - The code of the video on the service.
|
|
||||||
*
|
*
|
||||||
* @example
|
* See OpenAPI documentation for request/response schema.
|
||||||
* Request route: POST /internal/video/bulk-insert
|
|
||||||
* Request body:
|
|
||||||
* {
|
|
||||||
* "media_id": "019c064e-a03d-7cc3-b2ae-5d6850ea456b",
|
|
||||||
* "data": [
|
|
||||||
* {
|
|
||||||
* "episode": 1,
|
|
||||||
* "videos": [
|
|
||||||
* {
|
|
||||||
* "service_id": "019c0df6-f8fe-7565-82cd-9c29b20232ab",
|
|
||||||
* "code": "fzwu9n8ge2qt"
|
|
||||||
* }
|
|
||||||
* ]
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* "episode": 2,
|
|
||||||
* "videos": [
|
|
||||||
* {
|
|
||||||
* "service_id": "019c0df6-f8fe-7565-82cd-9c29b20232ab",
|
|
||||||
* "code": "w2maywh53rt8"
|
|
||||||
* }
|
|
||||||
* ]
|
|
||||||
* }
|
|
||||||
* ]
|
|
||||||
* },
|
|
||||||
*
|
|
||||||
* @returns {Promise<Object>}
|
|
||||||
* A response object indicating success or failure.
|
|
||||||
* Return example:
|
|
||||||
* {
|
|
||||||
* success: true,
|
|
||||||
* status: 201,
|
|
||||||
* message: "Videos inserted",
|
|
||||||
* data: { ...insertedVideos } // Data returned only if the env run on development mode
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* @throws {Object}
|
|
||||||
* An error response object if validation fails or an error occurs during bulk insert operation.
|
|
||||||
* Return example:
|
|
||||||
* {
|
|
||||||
* success: false,
|
|
||||||
* status: <Status Code>,
|
|
||||||
* message: "<Error Message>",
|
|
||||||
* error: { ...errorDetails } // Additional error details if available and the env run on development mode
|
|
||||||
* }
|
|
||||||
*/
|
*/
|
||||||
export const bulkInsertVideoController = async (ctx: {
|
export const bulkInsertVideoController = async (ctx: {
|
||||||
set: Context["set"];
|
set: Context["set"];
|
||||||
|
|||||||
@ -1,21 +1,22 @@
|
|||||||
import { Context } from "elysia";
|
import { Context, Static } from "elysia";
|
||||||
import { mainErrorHandler } from "../../../helpers/error/handler";
|
import { mainErrorHandler } from "../../../helpers/error/handler";
|
||||||
import { createHeroBannerService } from "../services/http/createHeroBanner.service";
|
import { createHeroBannerService } from "../services/http/createHeroBanner.service";
|
||||||
import { returnWriteResponse } from "../../../helpers/callback/httpResponse";
|
import { returnWriteResponse } from "../../../helpers/callback/httpResponse";
|
||||||
|
import { createHeroBannerSchema } from "../schemas/createHeroBanner.schema";
|
||||||
|
|
||||||
export interface CreateHeroBannerRequestBody {
|
/**
|
||||||
isClickable?: boolean;
|
* Create a new hero banner.
|
||||||
title?: string;
|
*
|
||||||
tags: string[];
|
* This controller handles the creation of a hero banner by accepting the necessary
|
||||||
description?: string;
|
* data in the request body, invoking the service to create the banner, and returning
|
||||||
buttonContent?: string;
|
* an created payload response.
|
||||||
buttonLink?: string;
|
*
|
||||||
imageUrl?: string;
|
* See OpenAPI documentation for request/response schema.
|
||||||
startDate: string;
|
*/
|
||||||
endDate: string;
|
export const createHeroBannerController = async (ctx: {
|
||||||
}
|
set: Context["set"];
|
||||||
|
body: Static<typeof createHeroBannerSchema.body>;
|
||||||
export const createHeroBannerController = async (ctx: Context & { body: CreateHeroBannerRequestBody }) => {
|
}) => {
|
||||||
try {
|
try {
|
||||||
const createdBanner = await createHeroBannerService(ctx.body);
|
const createdBanner = await createHeroBannerService(ctx.body);
|
||||||
return returnWriteResponse(ctx.set, 201, "Hero banner created successfully", createdBanner);
|
return returnWriteResponse(ctx.set, 201, "Hero banner created successfully", createdBanner);
|
||||||
|
|||||||
Reference in New Issue
Block a user