Replace Firebase Storage with MinIO and add user account features
- Storage Integration: * Remove Firebase Storage dependency and useFirebaseStorage composable * Implement direct MinIO uploads via POST /storage/upload with multipart/form-data * Upload canvas JSON, preview PNG, and production PNG as separate objects * Store public URLs and metadata in design records - Authentication & Registration: * Add email/password registration page with validation * Integrate backend user session via /auth/login endpoint * Store backendUser.id as ownerId in design records * Auto-sync backend session on Firebase auth state changes - User Account Pages: * Create profile page showing user details and backend session info * Create orders page with transaction history filtered by customerEmail * Add server proxy /api/orders to forward GET /transactions queries - Navigation Improvements: * Replace inline auth buttons with avatar dropdown menu * Add Profile, Orders, and Logout options to dropdown * Implement outside-click and route-change handlers for dropdown * Display user initials in avatar badge - API Updates: * Update transactions endpoint to accept amount as string * Format amount with .toFixed(2) in checkout success flow * Query orders by customerEmail instead of ownerId for consistency
This commit is contained in:
60
server/api/designs.post.ts
Normal file
60
server/api/designs.post.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<{
|
||||
designId: string;
|
||||
templateId: string;
|
||||
ownerEmail?: string | null;
|
||||
ownerId?: string | null;
|
||||
previewUrl?: string | null;
|
||||
productionUrl?: string | null;
|
||||
canvasJson: unknown;
|
||||
metadata?: Record<string, unknown>;
|
||||
}>(event);
|
||||
|
||||
if (!body?.designId || !body?.templateId || body.canvasJson === undefined) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing required design fields",
|
||||
});
|
||||
}
|
||||
|
||||
const config = useRuntimeConfig();
|
||||
const backendUrl = config.public?.backendUrl;
|
||||
|
||||
if (!backendUrl) {
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: "Backend URL not configured",
|
||||
});
|
||||
}
|
||||
|
||||
const payload = {
|
||||
designId: body.designId,
|
||||
templateId: body.templateId,
|
||||
ownerEmail: body.ownerEmail ?? null,
|
||||
ownerId: body.ownerId ?? null,
|
||||
previewUrl: body.previewUrl ?? null,
|
||||
productionUrl: body.productionUrl ?? null,
|
||||
canvasJson: body.canvasJson,
|
||||
metadata: body.metadata ?? {},
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
try {
|
||||
const result = await $fetch("/designs", {
|
||||
baseURL: backendUrl,
|
||||
method: "POST",
|
||||
body: payload,
|
||||
});
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
result,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error("[designs] Failed to forward design payload", err);
|
||||
throw createError({
|
||||
statusCode: 502,
|
||||
statusMessage: (err as Error)?.message ?? "Failed to persist design",
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user