25 lines
585 B
TypeScript
25 lines
585 B
TypeScript
import { getAuthenticatedUserId } from '../../../utils/auth';
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const userId = getAuthenticatedUserId(event);
|
|
|
|
// Simple admin check
|
|
if (userId !== 1) {
|
|
throw createError({ statusCode: 403, statusMessage: 'Forbidden' });
|
|
}
|
|
|
|
const updatedUser = await prisma.user.update({
|
|
where: { id: userId },
|
|
data: {
|
|
coins: {
|
|
increment: 1000
|
|
}
|
|
}
|
|
});
|
|
|
|
return {
|
|
message: 'Added 1000 coins.',
|
|
newBalance: updatedUser.coins,
|
|
};
|
|
});
|