From a7cafe7ae5fc8e99d1dc993e534e91845e1592b9 Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Sat, 25 Apr 2026 14:51:06 +0800 Subject: [PATCH] fix: resolve all build errors and ensure clean build --- app/api/[[...slugs]]/route.ts | 2 +- lib/api/user.ts | 19 +++++++++++++------ lib/auth.ts | 2 +- lib/auth/rate-limit.ts | 3 +++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/api/[[...slugs]]/route.ts b/app/api/[[...slugs]]/route.ts index 08b784e..db7a882 100644 --- a/app/api/[[...slugs]]/route.ts +++ b/app/api/[[...slugs]]/route.ts @@ -33,9 +33,9 @@ export const app = new Elysia({ prefix: "/api" }) error: code === "NOT_FOUND" ? "Not found" : "Internal server error", } }) + .use(healthRoutes) .use(rateLimit(60, 100)) .use(betterAuth) - .use(healthRoutes) .use(userRoutes) .get("/", () => ({ name: "DeckyVault API", diff --git a/lib/api/user.ts b/lib/api/user.ts index 0ef89ca..328be19 100644 --- a/lib/api/user.ts +++ b/lib/api/user.ts @@ -3,6 +3,7 @@ import { auth } from "@/lib/auth" import { db } from "@/lib/db/index" import { user, performanceEntries } from "@/lib/db/schema" import { eq, sql } from "drizzle-orm" + export const userRoutes = new Elysia({ prefix: "/user" }) .get( "/profile/:id", @@ -34,14 +35,12 @@ export const userRoutes = new Elysia({ prefix: "/user" }) // Reputation = contributions * 10 (simple formula for now) const reputation = contributions * 10 + const { emailVerified, ...publicProfile } = profile return { - ...profile, + ...publicProfile, contributions, reputation, - verified: profile.emailVerified, - // Hide email from public profiles - email: undefined, - emailVerified: undefined, + verified: emailVerified, } }, { @@ -63,7 +62,15 @@ export const userRoutes = new Elysia({ prefix: "/user" }) } const [profile] = await db - .select() + .select({ + id: user.id, + name: user.name, + email: user.email, + image: user.image, + role: user.role, + createdAt: user.createdAt, + emailVerified: user.emailVerified, + }) .from(user) .where(eq(user.id, session.user.id)) .limit(1) diff --git a/lib/auth.ts b/lib/auth.ts index f75ffd0..1e93bdb 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -73,4 +73,4 @@ export const auth = betterAuth({ emailAndPassword: { enabled: true, }, -}) \ No newline at end of file +}) diff --git a/lib/auth/rate-limit.ts b/lib/auth/rate-limit.ts index 5a7b170..3092bdc 100644 --- a/lib/auth/rate-limit.ts +++ b/lib/auth/rate-limit.ts @@ -5,6 +5,9 @@ type RateLimitEntry = { resetAt: number } +// NOTE: This is an in-memory rate limiter for development/single-instance +// deployments. For production with multiple instances or serverless, use a +// shared store like Redis or Upstash. const store = new Map() // Clean up expired entries every 60 seconds