media-detail #31
@ -1,17 +1,16 @@
|
|||||||
import { Context, Static } from "elysia";
|
import { Context, Static } from "elysia";
|
||||||
import { mainErrorHandler } from "../../../helpers/error/handler";
|
import { mainErrorHandler } from "../../../helpers/error/handler";
|
||||||
import { getMediaBySlugSchema } from "../schemas/getMediaBySlug.schema";
|
import { getMediaBySlugSchema } from "../schemas/getMediaBySlug.schema";
|
||||||
|
import { getMediaBySlugService } from "../services/http/getMediaBySlug.service";
|
||||||
|
import { returnReadResponse } from "../../../helpers/callback/httpResponse";
|
||||||
|
|
||||||
export const getMediaBySlugController = async (ctx: {
|
export const getMediaBySlugController = async (ctx: {
|
||||||
set: Context["set"];
|
set: Context["set"];
|
||||||
params: Static<typeof getMediaBySlugSchema.params>;
|
params: Static<typeof getMediaBySlugSchema.params>;
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
try {
|
||||||
return {
|
const mediaData = getMediaBySlugService(ctx.params.slug);
|
||||||
success: true,
|
return returnReadResponse(ctx.set, 200, "Media fetched successfully", mediaData);
|
||||||
status: 200,
|
|
||||||
message: `Media with slug '${ctx.params.slug}' fetched successfully`,
|
|
||||||
};
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return mainErrorHandler(ctx.set, error);
|
return mainErrorHandler(ctx.set, error);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
|
||||||
|
|
||||||
|
export const getMediaBySlugService = (slug: string) => {
|
||||||
|
try {
|
||||||
|
return `Mengambil media dengan slug '${slug}'`;
|
||||||
|
} catch (error) {
|
||||||
|
ErrorForwarder(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user