first
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import type { Handler } from 'hono';
|
||||
import { officerdb, eq, Users } from 'officerdb';
|
||||
import * as errors from '@@/custom-errors';
|
||||
|
||||
export const updateUserHandler: Handler = async function (ctx) {
|
||||
const { name, avatar } = ctx.get('body');
|
||||
const reqUser = ctx.get('user');
|
||||
|
||||
if (typeof name !== 'string') throw errors.BAD_REQUEST('Name is required');
|
||||
|
||||
await officerdb
|
||||
.update(Users)
|
||||
.set({ name, avatar: avatar ?? null })
|
||||
.where(eq(Users.id, reqUser.id));
|
||||
|
||||
return ctx.json({ ok: true });
|
||||
};
|
||||
Reference in New Issue
Block a user