add get all user controller

This commit is contained in:
rafiarrafif
2025-05-07 16:51:00 +07:00
parent 0f506debfb
commit afa05daab1
4 changed files with 36 additions and 6 deletions

View File

@ -1,5 +1,22 @@
import Elysia from "elysia";
import { handlePrismaError } from "../../../utils/databases/prisma/error/handler";
import {
returnErrorResponse,
returnReadResponse,
} from "../../../helpers/callback/httpResponse";
import { Context } from "elysia";
import { getAllUsersService } from "../services/getAllUser.service";
export const getAllUser = (ctx: Elysia) => {
return "Hello User Module";
export const getAllUser = async (ctx: Context) => {
try {
const allUser = await getAllUsersService();
return returnReadResponse(
ctx.set,
200,
"All user ranks successfully",
allUser
);
} catch (error) {
const { status, message, details } = handlePrismaError(error);
return returnErrorResponse(ctx.set, status, message, details);
}
};