✨ feat: add get all media endpoint
All checks were successful
Integration Tests / integration-tests (pull_request) Successful in 56s
All checks were successful
Integration Tests / integration-tests (pull_request) Successful in 56s
This commit is contained in:
20
src/modules/media/controllers/getAllMedia.controller.ts
Normal file
20
src/modules/media/controllers/getAllMedia.controller.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { Context } from "elysia";
|
||||
import { mainErrorHandler } from "../../../helpers/error/handler";
|
||||
import { getAllMediaService } from "../services/http/getAllMedia.service";
|
||||
import { returnReadResponse } from "../../../helpers/callback/httpResponse";
|
||||
|
||||
export const getAllMediaController = async (
|
||||
ctx: Context & { query: { page: string } },
|
||||
) => {
|
||||
try {
|
||||
const mediaData = await getAllMediaService(ctx.query.page);
|
||||
return returnReadResponse(
|
||||
ctx.set,
|
||||
200,
|
||||
"Media fetched successfully",
|
||||
mediaData,
|
||||
);
|
||||
} catch (error) {
|
||||
return mainErrorHandler(ctx.set, error);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user