feat: implement account updates on backend

This commit is contained in:
mrjvs
2026-08-09 17:36:34 +02:00
parent 4f5f46628b
commit 88ec0b9c53
2 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { AccountUpdateSchema } from "~~/shared/api-types";
export default defineEventHandler(async (event): Promise<void> => {
const body = await readZodBody(event, AccountUpdateSchema);
const apiFetch = useHttpApi(event);
const auth = enforceLoggedIn(event);
// There's no equivalent GRPC endpoint to use, so we're using the HTTP api
await apiFetch('/v1/user', {
headers: {
'Authorization': `Bearer ${auth.token}`,
},
body: {
mii: body.mii,
environment: body.environment
}
})
});

6
server/utils/httpApi.ts Normal file
View File

@@ -0,0 +1,6 @@
export function useHttpApi(event: H3Event) {
const config = useRuntimeConfig(event);
return $fetch.create({
baseURL: config.public.apiBase,
});
}