From 88ec0b9c53a3fec2e86a6dda0da61a73e7db3c6d Mon Sep 17 00:00:00 2001 From: mrjvs Date: Sun, 9 Aug 2026 17:36:34 +0200 Subject: [PATCH] feat: implement account updates on backend --- server/api/account/update.patch.ts | 18 ++++++++++++++++++ server/utils/httpApi.ts | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 server/api/account/update.patch.ts create mode 100644 server/utils/httpApi.ts diff --git a/server/api/account/update.patch.ts b/server/api/account/update.patch.ts new file mode 100644 index 0000000..107cd4e --- /dev/null +++ b/server/api/account/update.patch.ts @@ -0,0 +1,18 @@ +import { AccountUpdateSchema } from "~~/shared/api-types"; + +export default defineEventHandler(async (event): Promise => { + 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 + } + }) +}); diff --git a/server/utils/httpApi.ts b/server/utils/httpApi.ts new file mode 100644 index 0000000..c8a9ab3 --- /dev/null +++ b/server/utils/httpApi.ts @@ -0,0 +1,6 @@ +export function useHttpApi(event: H3Event) { + const config = useRuntimeConfig(event); + return $fetch.create({ + baseURL: config.public.apiBase, + }); +}