- added settings page and function

- add Role Ring for avatar and display role for user nav
This commit is contained in:
2026-01-06 21:37:53 +07:00
parent 8146565d2c
commit a4e96fe045
64 changed files with 2828 additions and 726 deletions

View File

@@ -0,0 +1,17 @@
import { authMiddleware } from '@/lib/middleware';
import { saveFile } from '@/utils/disk-storage';
import { createServerFn } from '@tanstack/react-start';
import z from 'zod';
export const uploadProfileImage = createServerFn({ method: 'POST' })
.middleware([authMiddleware])
.inputValidator(z.instanceof(FormData))
.handler(async ({ data: formData }) => {
const uuid = crypto.randomUUID();
const file = formData.get('file') as File;
if (!(file instanceof File)) throw new Error('File not found');
const imageKey = `${uuid}.${file.type.split('/')[1]}`;
const buffer = Buffer.from(await file.arrayBuffer());
await saveFile(imageKey, buffer);
return { imageKey };
});