add get all user controller
This commit is contained in:
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user