📝 docs: add documentation for bulk insert media
This commit is contained in:
@ -1,21 +0,0 @@
|
|||||||
import { Context } from "elysia";
|
|
||||||
import { mainErrorHandler } from "../../../helpers/error/handler";
|
|
||||||
import { bulkInsertAnimeService } from "../services/http/bulkInsertAnime.service";
|
|
||||||
import { returnWriteResponse } from "../../../helpers/callback/httpResponse";
|
|
||||||
import { bulkInsertCharWithVAService } from "../services/internal/bulkInsertCharWithVA.service";
|
|
||||||
|
|
||||||
export const bulkInsertAnimeController = async (
|
|
||||||
ctx: Context & { body: { mal_id: number } },
|
|
||||||
) => {
|
|
||||||
try {
|
|
||||||
const bulkInsertResult = await bulkInsertAnimeService(ctx.body.mal_id);
|
|
||||||
return returnWriteResponse(
|
|
||||||
ctx.set,
|
|
||||||
201,
|
|
||||||
"Bulk insert anime operation completed successfully",
|
|
||||||
bulkInsertResult,
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
return mainErrorHandler(ctx.set, error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
import { Context } from "elysia";
|
||||||
|
import { mainErrorHandler } from "../../../helpers/error/handler";
|
||||||
|
import { bulkInsertAnimeService } from "../services/http/bulkInsertAnime.service";
|
||||||
|
import { returnWriteResponse } from "../../../helpers/callback/httpResponse";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function bulkInsertAnimeController
|
||||||
|
* @description Insert new anime to the database only with mal_id. This operation including inserting related data such as genres, studios, producers, licensors, themes, demographics, and relations.
|
||||||
|
*
|
||||||
|
* @param {Context & { body: { mal_id: number } }} ctx
|
||||||
|
* The context object containing the request body.
|
||||||
|
* The body must include:
|
||||||
|
* - mal_id: number - The MyAnimeList ID of the anime to be inserted.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* Request route: POST /internal/anime/bulk-insert
|
||||||
|
* Request body:
|
||||||
|
* {
|
||||||
|
* "mal_id": 12345
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @returns {Promise<Object>}
|
||||||
|
* A response object indicating success or failure.
|
||||||
|
* Return example:
|
||||||
|
* {
|
||||||
|
* success: true,
|
||||||
|
* status: 201,
|
||||||
|
* message: "Bulk insert anime operation completed successfully",
|
||||||
|
* data: { ...bulkInsertResult } // 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 bulkInsertMediaController = async (
|
||||||
|
ctx: Context & { body: { mal_id: number } },
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
const bulkInsertResult = await bulkInsertAnimeService(ctx.body.mal_id);
|
||||||
|
return returnWriteResponse(
|
||||||
|
ctx.set,
|
||||||
|
201,
|
||||||
|
"Bulk insert anime operation completed successfully",
|
||||||
|
bulkInsertResult,
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return mainErrorHandler(ctx.set, error);
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import Elysia from "elysia";
|
import Elysia from "elysia";
|
||||||
import { bulkInsertAnimeController } from "./controllers/bulkInsertAnime.controller";
|
|
||||||
import { bulkInsertEpisodeController } from "./controllers/bulkInsertEpisode.controller";
|
import { bulkInsertEpisodeController } from "./controllers/bulkInsertEpisode.controller";
|
||||||
|
import { bulkInsertMediaController } from "./controllers/bulkInsertMedia.controller";
|
||||||
|
|
||||||
export const internalModule = new Elysia({ prefix: "/internal" })
|
export const internalModule = new Elysia({ prefix: "/internal" })
|
||||||
.post("/media/bulk-insert", bulkInsertAnimeController)
|
.post("/media/bulk-insert", bulkInsertMediaController)
|
||||||
.post("/episode/bulk-insert", bulkInsertEpisodeController);
|
.post("/episode/bulk-insert", bulkInsertEpisodeController);
|
||||||
|
|||||||
Reference in New Issue
Block a user