From aa66e7e23a2449f3e5a2598f43b36220c5a366cc Mon Sep 17 00:00:00 2001 From: Ashish Date: Sun, 10 Aug 2025 15:15:54 +0530 Subject: [PATCH 1/5] Fixed bugs --- .github/workflows/build.yml | 22 ++++++++++++++++++++++ apps/merchant-app/app/api/user/route.ts | 10 +++++----- apps/merchant-app/app/page.tsx | 2 +- apps/merchant-app/lib/auth.ts | 23 +++++++++++++---------- apps/user-app/app/api/user/route.ts | 2 +- apps/user-app/app/lib/auth.ts | 11 +++++++---- apps/user-app/types/next-auth.d.ts | 13 +++++++++++++ packages/db/tsconfig.json | 2 +- packages/store/package.json | 2 +- 9 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 apps/user-app/types/next-auth.d.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..f691d9cd --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,22 @@ +name: Build on PR + +on: + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install Dependencies + run: npm install + + - name: Run Build + run: npm run build diff --git a/apps/merchant-app/app/api/user/route.ts b/apps/merchant-app/app/api/user/route.ts index fd5df926..736fb8df 100644 --- a/apps/merchant-app/app/api/user/route.ts +++ b/apps/merchant-app/app/api/user/route.ts @@ -1,13 +1,13 @@ import { NextResponse } from "next/server" -import { PrismaClient } from "@repo/db/client"; - -const client = new PrismaClient(); +import prisma from "@repo/db/client"; export const GET = async () => { - await client.user.create({ + await prisma.user.create({ data: { email: "asd", - name: "adsads" + name: "adsads", + password:"secret", + number:"123" } }) return NextResponse.json({ diff --git a/apps/merchant-app/app/page.tsx b/apps/merchant-app/app/page.tsx index f72d01d4..473ed22c 100644 --- a/apps/merchant-app/app/page.tsx +++ b/apps/merchant-app/app/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { useBalance } from "@repo/store/balance"; +import {useBalance} from "@repo/store/balance"; export default function() { const balance = useBalance(); diff --git a/apps/merchant-app/lib/auth.ts b/apps/merchant-app/lib/auth.ts index 8d38ac07..49ff49eb 100644 --- a/apps/merchant-app/lib/auth.ts +++ b/apps/merchant-app/lib/auth.ts @@ -1,5 +1,8 @@ import GoogleProvider from "next-auth/providers/google"; import db from "@repo/db/client"; +import { signIn } from "next-auth/react"; +import { Account, User } from "next-auth"; +import { AdapterUser } from "next-auth/adapters"; export const authOptions = { providers: [ @@ -9,19 +12,19 @@ export const authOptions = { }) ], callbacks: { - async signIn({ user, account }: { - user: { - email: string; - name: string - }, - account: { - provider: "google" | "github" - } - }) { + async signIn({ + user,account + }: { + user:User | AdapterUser; account : Account | null + }) + + { console.log("hi signin") if (!user || !user.email) { return false; } + if(!account) + return false; await db.merchant.upsert({ select: { @@ -32,7 +35,7 @@ export const authOptions = { }, create: { email: user.email, - name: user.name, + name: user.name ?? "", auth_type: account.provider === "google" ? "Google" : "Github" // Use a prisma type here }, update: { diff --git a/apps/user-app/app/api/user/route.ts b/apps/user-app/app/api/user/route.ts index c6fb73a4..896065f2 100644 --- a/apps/user-app/app/api/user/route.ts +++ b/apps/user-app/app/api/user/route.ts @@ -4,7 +4,7 @@ import { authOptions } from "../../lib/auth"; export const GET = async () => { const session = await getServerSession(authOptions); - if (session.user) { + if (session?.user) { return NextResponse.json({ user: session.user }) diff --git a/apps/user-app/app/lib/auth.ts b/apps/user-app/app/lib/auth.ts index 56d82dd7..e53e5dee 100644 --- a/apps/user-app/app/lib/auth.ts +++ b/apps/user-app/app/lib/auth.ts @@ -1,6 +1,8 @@ import db from "@repo/db/client"; import CredentialsProvider from "next-auth/providers/credentials" import bcrypt from "bcrypt"; +import { JWT } from "next-auth/jwt"; +import { Session } from "next-auth"; export const authOptions = { providers: [ @@ -56,10 +58,11 @@ export const authOptions = { secret: process.env.JWT_SECRET || "secret", callbacks: { // TODO: can u fix the type here? Using any is bad - async session({ token, session }: any) { - session.user.id = token.sub - - return session + async session({ token, session }: {session: Session; token: JWT}) { + if(session.user && token.sub){ + session.user.id = token.sub; + } + return session; } } } diff --git a/apps/user-app/types/next-auth.d.ts b/apps/user-app/types/next-auth.d.ts new file mode 100644 index 00000000..ba0ac34b --- /dev/null +++ b/apps/user-app/types/next-auth.d.ts @@ -0,0 +1,13 @@ +// apps/user-app/types/next-auth.d.ts +import NextAuth from "next-auth"; + +declare module "next-auth" { + interface Session { + user?: { + id?: string; + name?: string | null; + email?: string | null; + image?: string | null; + }; + } +} diff --git a/packages/db/tsconfig.json b/packages/db/tsconfig.json index 872a7a30..5fd6fc80 100644 --- a/packages/db/tsconfig.json +++ b/packages/db/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "dist" }, - "include": ["src"], + "include": ["."], "exclude": ["node_modules", "dist"] } \ No newline at end of file diff --git a/packages/store/package.json b/packages/store/package.json index b92ae809..c652f651 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -6,6 +6,6 @@ "recoil": "^0.7.7" }, "exports": { - "./balance": "./src/hooks/useBalance" + "./balance": "./src/hooks/useBalance.ts" } } From 39104cef22e01da3fb6185ab117ba8e5fdad8967 Mon Sep 17 00:00:00 2001 From: Ashish Bastola <162864039+Ashish2736@users.noreply.github.com> Date: Sun, 10 Aug 2025 15:17:26 +0530 Subject: [PATCH 2/5] Delete .github/workflows directory --- .github/workflows/build.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index f691d9cd..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Build on PR - -on: - pull_request: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '20' - - - name: Install Dependencies - run: npm install - - - name: Run Build - run: npm run build From cf5d023e81e4a424aea0b6c38c4833f25ce23d91 Mon Sep 17 00:00:00 2001 From: Ashish Date: Sun, 10 Aug 2025 15:18:57 +0530 Subject: [PATCH 3/5] fixed build --- .github/workflows/build.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..98aafd2b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,25 @@ +name: Build on PR + +on: + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install Dependencies + run: npm install + + - name: Run Build + run: npm run build + + + From 8af7a75d5d35297974b22b944ea78bd2324d1231 Mon Sep 17 00:00:00 2001 From: Ashish Date: Sun, 10 Aug 2025 15:36:04 +0530 Subject: [PATCH 4/5] Added workflows --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 98aafd2b..f691d9cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,3 @@ jobs: - name: Run Build run: npm run build - - - From 9dc4011533c25ba37bde9a0a300662636642235d Mon Sep 17 00:00:00 2001 From: Ashish Date: Sun, 10 Aug 2025 16:10:07 +0530 Subject: [PATCH 5/5] fix workflow --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5aee3779..f691d9cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,5 +20,3 @@ jobs: - name: Run Build run: npm run build - -