Skip to content

Starfire world peace#30

Merged
StarDust130 merged 12 commits into
mainfrom
starfire-world-peace
Jun 2, 2026
Merged

Starfire world peace#30
StarDust130 merged 12 commits into
mainfrom
starfire-world-peace

Conversation

@StarDust130

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings June 2, 2026 02:55
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
star-fire-web Ready Ready Preview, Comment Jun 2, 2026 2:55am

@StarDust130 StarDust130 merged commit 7ea396b into main Jun 2, 2026
5 of 6 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Clerk-to-backend user-sync flow: a new /api/v1/auth/sync route on the core service finds-or-creates a User row keyed by clerkId, and a new client-side useAuthSync hook calls it on login and caches the returned UUID in localStorage for use as userId in chat requests. Also restores the previously commented-out validate(chatSchema) middleware on the chat route and removes an unused Tooltip import.

Changes:

  • New backend auth module (route/controller/service/repository) implementing a findOrCreate user-sync endpoint.
  • New useAuthSync React hook wired into the dashboard layout via an AuthProvider wrapper; ChatWindow now reads userId from localStorage instead of a hard-coded UUID.
  • Re-enabled validate(chatSchema) on the chat POST route.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
apps/core/src/app.ts Mounts the new authRouter under /api/v1/auth.
apps/core/src/modules/auth/auth.route.ts New router exposing POST /sync.
apps/core/src/modules/auth/auth.controller.ts Calls authSync and returns { success, userId }.
apps/core/src/modules/auth/auth.service.ts Find-or-create user by clerkId via Prisma.
apps/core/src/modules/auth/auth.repository.ts Duplicate of the service file with identical logic.
apps/core/src/modules/auth/auth.schema.ts Empty placeholder for a validation schema.
apps/core/src/modules/chat/chat.route.ts Re-enables validate(chatSchema) on the chat route.
apps/web/app/hooks/use-auth-sync.ts Client hook posting Clerk profile to the sync endpoint and caching userId.
apps/web/app/dashboard/layout.tsx Imports the hook and mounts a null-returning AuthProvider.
apps/web/app/components/chat/ChatWindow.tsx Sources userId from localStorage instead of a hard-coded UUID.
apps/web/app/components/chat/ChatInput.tsx Removes an unused Tooltip import.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +35
import { prisma } from "../../lib/prisma.js";

// 🔄 Find or create user
export async function authSync(data: {
clerkId: string;

name: string;

email?: string;
}) {
// 1️⃣ Find existing user
const existingUser = await prisma.user.findUnique({
where: {
clerkId: data.clerkId,
},
});

// 2️⃣ Return if exists
if (existingUser) {
return existingUser;
}

// 3️⃣ Create new user
return prisma.user.create({
data: {
clerkId: data.clerkId,

name: data.name,

// Prisma expects string | null for optional string fields when
// exactOptionalPropertyTypes is enabled.
email: data.email ?? null,
},
});
}
Comment on lines +8 to +12
router.post(
"/sync",

authSyncController,
);
Comment on lines +20 to +30
const response = await axios.post(
"http://localhost:8080/api/v1/auth/sync",

{
clerkId: user.id,

name: user.fullName || "User",

email: user.primaryEmailAddress?.emailAddress,
},
);
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
userId: "9eba1881-f6aa-4d0e-a85d-ec67458b8a76",
userId: localStorage.getItem("userId"),

<div className="flex-1 overflow-y-auto overflow-x-hidden relative custom-scrollbar z-0">
<div className="p-4 md:p-8 lg:p-10 w-full mx-auto min-h-max max-w-[1600px]">
<AuthProvider />
Comment on lines +64 to +68
function AuthProvider() {
useAuthSync();

return null;
} No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants