Test AUTH - 30 Jul

This commit is contained in:
2025-07-30 12:11:17 +08:00
parent c11cc421a4
commit 4e61695649
14 changed files with 619 additions and 13 deletions

View File

@@ -0,0 +1,35 @@
// /api/user/update.ts
import prisma from '@/lib/prisma';
import { Context } from 'elysia';
export default async function userUpdate(context: Context) {
const { id } = context.params as { id: string };
const body = await context.body as {
nama?: string;
email?: string;
password?: string;
roleId?: string;
isActive?: boolean;
};
try {
const updated = await prisma.user.update({
where: { id },
data: {
...body,
},
});
return {
success: true,
message: 'User berhasil diupdate',
data: updated,
};
} catch (error) {
console.error(error);
return {
success: false,
message: 'Gagal mengupdate user',
};
}
}