mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-08-22 16:47:16 -05:00
feat: implement account updates on backend
This commit is contained in:
18
server/api/account/update.patch.ts
Normal file
18
server/api/account/update.patch.ts
Normal 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
6
server/utils/httpApi.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export function useHttpApi(event: H3Event) {
|
||||
const config = useRuntimeConfig(event);
|
||||
return $fetch.create({
|
||||
baseURL: config.public.apiBase,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user