import { loginUser } from "#server/service/auth"; import { toPublicAuthError } from "#server/service/auth/errors"; import { setSessionCookie } from "#server/service/auth/cookie"; type LoginBody = { username: string; password: string; }; export default defineWrappedResponseHandler(async (event) => { try { const body = await readBody(event); const result = await loginUser(body); setSessionCookie(event, result.sessionId); return R.success({ user: result.user, }); } catch (err) { throw toPublicAuthError(err); } });