diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..c51ae2f
--- /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: '21'
+
+ - name: Install Dependencies
+ run: npm install
+
+ - name: Generate prisma client
+ run: cd packages/db && npx prisma generate && cd ../..
+
+ - name: Run Build
+ run: npm run build
\ No newline at end of file
diff --git a/apps/bank-webhook/package.json b/apps/bank-webhook/package.json
new file mode 100644
index 0000000..a78a9fb
--- /dev/null
+++ b/apps/bank-webhook/package.json
@@ -0,0 +1,17 @@
+{
+ "name": "bank-webhook",
+ "version": "1.0.0",
+ "description": "",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "keywords": [],
+ "author": "",
+ "license": "ISC",
+ "dependencies": {
+ "@repo/common" : "*",
+ "@repo/db" : "*",
+ "@types/express": "^4.17.21"
+ }
+}
diff --git a/apps/bank-webhook/src/index.ts b/apps/bank-webhook/src/index.ts
new file mode 100644
index 0000000..27ac9f7
--- /dev/null
+++ b/apps/bank-webhook/src/index.ts
@@ -0,0 +1,2 @@
+const common = require ("@repo/common/type")
+console.log(common.DATA_URL)
\ No newline at end of file
diff --git a/apps/bank-webhook/tsconfig.json b/apps/bank-webhook/tsconfig.json
new file mode 100644
index 0000000..5e3db2b
--- /dev/null
+++ b/apps/bank-webhook/tsconfig.json
@@ -0,0 +1,8 @@
+{
+ "extends": "@repo/typescript-config/base.json",
+ "compilerOptions": {
+ "outDir": "dist"
+ },
+ "include": ["src"],
+ "exclude": ["node_modules", "dist"]
+}
diff --git a/apps/merchant-app/app/api/auth/[...nextauth]/route.ts b/apps/merchant-app/app/api/auth/[...nextauth]/route.ts
index 2a79844..d1efa50 100644
--- a/apps/merchant-app/app/api/auth/[...nextauth]/route.ts
+++ b/apps/merchant-app/app/api/auth/[...nextauth]/route.ts
@@ -1,6 +1,59 @@
-import NextAuth from "next-auth"
-import { authOptions } from "../../../../lib/auth"
-const handler = NextAuth(authOptions)
+import prisma from "@repo/db/client";
+import nextAuth from "next-auth";
+import CredentialsProvider from "next-auth/providers/credentials"
+import Google from "next-auth/providers/google";
-export { handler as GET, handler as POST }
\ No newline at end of file
+
+const handler = nextAuth({
+ providers: [
+ CredentialsProvider({
+ name: 'Credentials',
+ credentials: {
+ email : { label: "Email", type: "email",placeholder:"Enter your Email address"},
+ password: { label: "Password", type: "password",placeholder: "Enter your Password"}
+ },
+ // TODO: User credentials type from next-aut
+ // @ts-ignore
+ async authorize(credentials: any) {
+ console.log(credentials);
+ // Do zod validation, OTP validation here
+ const existingUser = await prisma.merchant.findFirst({
+ where: {
+ email: credentials.email,
+ password : credentials.password
+ }
+ });
+
+ if (existingUser) {
+
+ return {
+ email: existingUser.email
+ }
+ }
+
+ try {
+ const merchant = await prisma.merchant.create({
+ data: {
+ email : credentials.email,
+ password : credentials.password
+ }
+ });
+ return {
+ email: merchant.email
+ }
+ } catch(e) {
+ console.error(e);
+ }
+ return null
+ },
+ }),
+ Google({
+ clientId:process.env.GOOGLE_CLIENT_ID || "",
+ clientSecret: process.env.GOOGLE_SECRET || ""
+ })
+ ],
+ secret: process.env.NEXTAUTH_SECRET || "saurabh412",
+ })
+
+ export { handler as GET, handler as POST}
\ No newline at end of file
diff --git a/apps/merchant-app/app/api/user/route.ts b/apps/merchant-app/app/api/user/route.ts
deleted file mode 100644
index fd5df92..0000000
--- a/apps/merchant-app/app/api/user/route.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { NextResponse } from "next/server"
-import { PrismaClient } from "@repo/db/client";
-
-const client = new PrismaClient();
-
-export const GET = async () => {
- await client.user.create({
- data: {
- email: "asd",
- name: "adsads"
- }
- })
- return NextResponse.json({
- message: "hi there"
- })
-}
\ No newline at end of file
diff --git a/apps/merchant-app/app/layout.tsx b/apps/merchant-app/app/layout.tsx
index f226b4a..35b4aa7 100644
--- a/apps/merchant-app/app/layout.tsx
+++ b/apps/merchant-app/app/layout.tsx
@@ -1,7 +1,7 @@
import "./globals.css";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
-import { Providers } from "../provider";
+import Provider from "../provider";
const inter = Inter({ subsets: ["latin"] });
@@ -17,9 +17,10 @@ export default function RootLayout({
}): JSX.Element {
return (
-
+
{children}
-
+
+
);
}
diff --git a/apps/merchant-app/app/page.tsx b/apps/merchant-app/app/page.tsx
index f72d01d..6c82239 100644
--- a/apps/merchant-app/app/page.tsx
+++ b/apps/merchant-app/app/page.tsx
@@ -1,10 +1,19 @@
-"use client";
+"use client"
+import { signIn, signOut, useSession } from "next-auth/react";
-import { useBalance } from "@repo/store/balance";
-
-export default function() {
- const balance = useBalance();
- return
- hi there {balance}
-
+export default function(){
+ const session = useSession()
+ return(
+ <>
+
+
+
+
+
+
+
+
+ {JSON.stringify(session)}
+ >
+ )
}
\ No newline at end of file
diff --git a/apps/merchant-app/lib/auth.ts b/apps/merchant-app/lib/auth.ts
deleted file mode 100644
index 8d38ac0..0000000
--- a/apps/merchant-app/lib/auth.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import GoogleProvider from "next-auth/providers/google";
-import db from "@repo/db/client";
-
-export const authOptions = {
- providers: [
- GoogleProvider({
- clientId: process.env.GOOGLE_CLIENT_ID || "",
- clientSecret: process.env.GOOGLE_CLIENT_SECRET || ""
- })
- ],
- callbacks: {
- async signIn({ user, account }: {
- user: {
- email: string;
- name: string
- },
- account: {
- provider: "google" | "github"
- }
- }) {
- console.log("hi signin")
- if (!user || !user.email) {
- return false;
- }
-
- await db.merchant.upsert({
- select: {
- id: true
- },
- where: {
- email: user.email
- },
- create: {
- email: user.email,
- name: user.name,
- auth_type: account.provider === "google" ? "Google" : "Github" // Use a prisma type here
- },
- update: {
- name: user.name,
- auth_type: account.provider === "google" ? "Google" : "Github" // Use a prisma type here
- }
- });
-
- return true;
- }
- },
- secret: process.env.NEXTAUTH_SECRET || "secret"
- }
\ No newline at end of file
diff --git a/apps/merchant-app/provider.tsx b/apps/merchant-app/provider.tsx
index 635b0bd..8c2edf4 100644
--- a/apps/merchant-app/provider.tsx
+++ b/apps/merchant-app/provider.tsx
@@ -1,10 +1,13 @@
"use client"
-import { RecoilRoot } from "recoil";
-import { SessionProvider } from "next-auth/react";
-export const Providers = ({children}: {children: React.ReactNode}) => {
- return
-
- {children}
-
-
+import { SessionProvider } from "next-auth/react"
+import {RecoilRoot} from "recoil"
+
+export default function Provider({children}:any){
+ return(
+
+
+ {children}
+
+
+ )
}
\ No newline at end of file
diff --git a/apps/user-app/app/api/auth/[...nextauth]/route.ts b/apps/user-app/app/api/auth/[...nextauth]/route.ts
index 1cf7c68..83bfcde 100644
--- a/apps/user-app/app/api/auth/[...nextauth]/route.ts
+++ b/apps/user-app/app/api/auth/[...nextauth]/route.ts
@@ -1,6 +1,58 @@
-import NextAuth from "next-auth"
-import { authOptions } from "../../../lib/auth"
-const handler = NextAuth(authOptions)
+import prisma from "@repo/db/client";
+import nextAuth from "next-auth";
+import CredentialsProvider from "next-auth/providers/credentials"
-export { handler as GET, handler as POST }
\ No newline at end of file
+interface Credentials {
+ email : string
+ password : string
+}
+
+const handler = nextAuth({
+ providers: [
+ CredentialsProvider({
+ name: 'Credentials',
+ credentials: {
+ email : { label: "Email", type: "email",placeholder:"Enter your Email address"},
+ password: { label: "Password", type: "password",placeholder: "Enter your Password"}
+ },
+ // TODO: User credentials type from next-aut
+ // @ts-ignore
+ async authorize(credentials:Credentials) : Promise<{email : string} | null> {
+ console.log(credentials);
+ // Do zod validation, OTP validation here
+ const existingUser = await prisma.user.findFirst({
+ where: {
+ email: credentials.email,
+ password : credentials.password
+ }
+ });
+
+ if (existingUser) {
+
+ return {
+ email: existingUser.email
+ }
+ }
+
+ try {
+ const user = await prisma.user.create({
+ data: {
+ email : credentials.email,
+ password : credentials.password
+ }
+ });
+ return {
+ email: user.email
+ }
+ } catch(e) {
+ console.error(e);
+ }
+ return null
+ },
+ })
+ ],
+ secret: process.env.NEXTAUTH_SECRET || "saurabh412",
+ })
+
+ export { handler as GET, handler as POST}
\ No newline at end of file
diff --git a/apps/user-app/app/api/user/route.ts b/apps/user-app/app/api/user/route.ts
index c6fb73a..bf4a31c 100644
--- a/apps/user-app/app/api/user/route.ts
+++ b/apps/user-app/app/api/user/route.ts
@@ -1,17 +1,10 @@
import { getServerSession } from "next-auth"
import { NextResponse } from "next/server";
-import { authOptions } from "../../lib/auth";
-export const GET = async () => {
- const session = await getServerSession(authOptions);
- if (session.user) {
- return NextResponse.json({
- user: session.user
- })
- }
+export async function GET() {
+ const session = await getServerSession();
+
return NextResponse.json({
- message: "You are not logged in"
- }, {
- status: 403
+ email: session?.user?.email,
})
}
\ No newline at end of file
diff --git a/apps/user-app/app/layout.tsx b/apps/user-app/app/layout.tsx
index f226b4a..5d69902 100644
--- a/apps/user-app/app/layout.tsx
+++ b/apps/user-app/app/layout.tsx
@@ -10,13 +10,9 @@ export const metadata: Metadata = {
description: "Generated by create turbo",
};
-export default function RootLayout({
- children,
-}: {
- children: React.ReactNode;
-}): JSX.Element {
+export default function RootLayout({children,}: {children: React.ReactNode;}): JSX.Element {
return (
-
+
{children}
diff --git a/apps/user-app/app/lib/auth.ts b/apps/user-app/app/lib/auth.ts
deleted file mode 100644
index 56d82dd..0000000
--- a/apps/user-app/app/lib/auth.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import db from "@repo/db/client";
-import CredentialsProvider from "next-auth/providers/credentials"
-import bcrypt from "bcrypt";
-
-export const authOptions = {
- providers: [
- CredentialsProvider({
- name: 'Credentials',
- credentials: {
- phone: { label: "Phone number", type: "text", placeholder: "1231231231", required: true },
- password: { label: "Password", type: "password", required: true }
- },
- // TODO: User credentials type from next-aut
- async authorize(credentials: any) {
- // Do zod validation, OTP validation here
- const hashedPassword = await bcrypt.hash(credentials.password, 10);
- const existingUser = await db.user.findFirst({
- where: {
- number: credentials.phone
- }
- });
-
- if (existingUser) {
- const passwordValidation = await bcrypt.compare(credentials.password, existingUser.password);
- if (passwordValidation) {
- return {
- id: existingUser.id.toString(),
- name: existingUser.name,
- email: existingUser.number
- }
- }
- return null;
- }
-
- try {
- const user = await db.user.create({
- data: {
- number: credentials.phone,
- password: hashedPassword
- }
- });
-
- return {
- id: user.id.toString(),
- name: user.name,
- email: user.number
- }
- } catch(e) {
- console.error(e);
- }
-
- return null
- },
- })
- ],
- 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
- }
- }
- }
-
\ No newline at end of file
diff --git a/apps/user-app/app/page.tsx b/apps/user-app/app/page.tsx
index 6f7c4ae..d798cf4 100644
--- a/apps/user-app/app/page.tsx
+++ b/apps/user-app/app/page.tsx
@@ -1,12 +1,11 @@
-"use client"
-import { signIn, signOut, useSession } from "next-auth/react";
-import { Appbar } from "@repo/ui/appbar";
+import { getServerSession } from "next-auth";
+import { redirect } from 'next/navigation'
-export default function Page(): JSX.Element {
- const session = useSession();
- return (
-
- );
-}
+export default async function Page() {
+ const session = await getServerSession();
+ if (session?.user) {
+ redirect('/user')
+ } else {
+ redirect('/api/auth/signin')
+ }
+}
\ No newline at end of file
diff --git a/apps/user-app/app/user/page.tsx b/apps/user-app/app/user/page.tsx
new file mode 100644
index 0000000..73d4477
--- /dev/null
+++ b/apps/user-app/app/user/page.tsx
@@ -0,0 +1,35 @@
+// import { getServerSession } from "next-auth"
+
+// export default async function Home() {
+// const session = await getServerSession()
+
+// if (!session) {
+// return (
+//
+// You are not signed in.
+//
+// )
+// }
+"use client"
+ import { signIn, signOut, useSession} from "next-auth/react";
+
+ export default function(){
+ const session = useSession()
+ return(
+ <>
+
+
+
+
+
+
+
+
+ {session.status}
+ hii there
+ {session.data ? `Hello ${session.data.user}` : 'You are not logged in'}
+
+ {JSON.stringify(session)}
+ >
+ )
+ }
\ No newline at end of file
diff --git a/apps/user-app/package.json b/apps/user-app/package.json
index 4f85ee6..406956a 100644
--- a/apps/user-app/package.json
+++ b/apps/user-app/package.json
@@ -9,6 +9,7 @@
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
+ "@repo/db": "*",
"@repo/store": "*",
"@repo/ui": "*",
"@types/bcrypt": "^5.0.2",
@@ -16,7 +17,8 @@
"next": "^14.1.1",
"next-auth": "^4.24.7",
"react": "^18.2.0",
- "react-dom": "^18.2.0"
+ "react-dom": "^18.2.0",
+ "zod": "^3.22.4"
},
"devDependencies": {
"@next/eslint-plugin-next": "^14.1.1",
diff --git a/apps/user-app/provider.tsx b/apps/user-app/provider.tsx
index 7835707..f5b75cd 100644
--- a/apps/user-app/provider.tsx
+++ b/apps/user-app/provider.tsx
@@ -1,11 +1,13 @@
"use client"
-import { RecoilRoot } from "recoil";
import { SessionProvider } from "next-auth/react";
+import { RecoilRoot } from "recoil";
-export const Providers = ({children}: {children: React.ReactNode}) => {
- return
-
+export function Providers({children}:any){
+return(
+
+
{children}
+ )
}
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index eec9a38..40680c6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,6 +19,15 @@
"node": ">=18"
}
},
+ "apps/bank-webhook": {
+ "version": "1.0.0",
+ "license": "ISC",
+ "dependencies": {
+ "@repo/common": "*",
+ "@repo/db": "*",
+ "@types/express": "^4.17.21"
+ }
+ },
"apps/docs": {
"version": "1.0.0",
"extraneous": true,
@@ -69,6 +78,7 @@
"name": "docs",
"version": "1.0.0",
"dependencies": {
+ "@repo/db": "*",
"@repo/store": "*",
"@repo/ui": "*",
"@types/bcrypt": "^5.0.2",
@@ -76,7 +86,8 @@
"next": "^14.1.1",
"next-auth": "^4.24.7",
"react": "^18.2.0",
- "react-dom": "^18.2.0"
+ "react-dom": "^18.2.0",
+ "zod": "^3.22.4"
},
"devDependencies": {
"@next/eslint-plugin-next": "^14.1.1",
@@ -1222,6 +1233,10 @@
"@prisma/debug": "5.11.0"
}
},
+ "node_modules/@repo/common": {
+ "resolved": "packages/common",
+ "link": true
+ },
"node_modules/@repo/db": {
"resolved": "packages/db",
"link": true
@@ -1339,6 +1354,23 @@
"@types/node": "*"
}
},
+ "node_modules/@types/body-parser": {
+ "version": "1.19.5",
+ "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz",
+ "integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==",
+ "dependencies": {
+ "@types/connect": "*",
+ "@types/node": "*"
+ }
+ },
+ "node_modules/@types/connect": {
+ "version": "3.4.38",
+ "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz",
+ "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==",
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@types/eslint": {
"version": "8.56.6",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.6.tgz",
@@ -1355,6 +1387,28 @@
"integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
"dev": true
},
+ "node_modules/@types/express": {
+ "version": "4.17.21",
+ "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz",
+ "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==",
+ "dependencies": {
+ "@types/body-parser": "*",
+ "@types/express-serve-static-core": "^4.17.33",
+ "@types/qs": "*",
+ "@types/serve-static": "*"
+ }
+ },
+ "node_modules/@types/express-serve-static-core": {
+ "version": "4.19.0",
+ "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.0.tgz",
+ "integrity": "sha512-bGyep3JqPCRry1wq+O5n7oiBgGWmeIJXPjXXCo8EK0u8duZGSYar7cGqd3ML2JUsLGeB7fmc06KYo9fLGWqPvQ==",
+ "dependencies": {
+ "@types/node": "*",
+ "@types/qs": "*",
+ "@types/range-parser": "*",
+ "@types/send": "*"
+ }
+ },
"node_modules/@types/glob": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz",
@@ -1365,6 +1419,11 @@
"@types/node": "*"
}
},
+ "node_modules/@types/http-errors": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz",
+ "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA=="
+ },
"node_modules/@types/inquirer": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-6.5.0.tgz",
@@ -1405,6 +1464,11 @@
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==",
"dev": true
},
+ "node_modules/@types/mime": {
+ "version": "1.3.5",
+ "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz",
+ "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w=="
+ },
"node_modules/@types/minimatch": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz",
@@ -1431,6 +1495,16 @@
"integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==",
"dev": true
},
+ "node_modules/@types/qs": {
+ "version": "6.9.14",
+ "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.14.tgz",
+ "integrity": "sha512-5khscbd3SwWMhFqylJBLQ0zIu7c1K6Vz0uBIt915BI3zV0q1nfjRQD3RqSBcPaO6PHEF4ov/t9y89fSiyThlPA=="
+ },
+ "node_modules/@types/range-parser": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz",
+ "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ=="
+ },
"node_modules/@types/react": {
"version": "18.2.69",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.69.tgz",
@@ -1463,6 +1537,25 @@
"integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==",
"dev": true
},
+ "node_modules/@types/send": {
+ "version": "0.17.4",
+ "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz",
+ "integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==",
+ "dependencies": {
+ "@types/mime": "^1",
+ "@types/node": "*"
+ }
+ },
+ "node_modules/@types/serve-static": {
+ "version": "1.15.7",
+ "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz",
+ "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==",
+ "dependencies": {
+ "@types/http-errors": "*",
+ "@types/node": "*",
+ "@types/send": "*"
+ }
+ },
"node_modules/@types/through": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/@types/through/-/through-0.0.33.tgz",
@@ -2343,6 +2436,10 @@
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
+ "node_modules/bank-webhook": {
+ "resolved": "apps/bank-webhook",
+ "link": true
+ },
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@@ -9799,6 +9896,19 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/zod": {
+ "version": "3.22.4",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz",
+ "integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==",
+ "funding": {
+ "url": "https://github.com/sponsors/colinhacks"
+ }
+ },
+ "packages/common": {
+ "name": "@repo/common",
+ "version": "1.0.0",
+ "license": "ISC"
+ },
"packages/db": {
"name": "@repo/db",
"version": "0.0.0",
diff --git a/packages/common/package.json b/packages/common/package.json
new file mode 100644
index 0000000..d0791eb
--- /dev/null
+++ b/packages/common/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "@repo/common",
+ "version": "1.0.0",
+ "description": "",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "exports":{
+ "./type" : "./src/index.ts"
+ },
+ "keywords": [],
+ "author": "",
+ "license": "ISC"
+}
diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts
new file mode 100644
index 0000000..4d7c4e2
--- /dev/null
+++ b/packages/common/src/index.ts
@@ -0,0 +1,4 @@
+
+module.exports = {
+ DATA_URL: "https://google.com.in"
+};
diff --git a/packages/common/tsconfig.json b/packages/common/tsconfig.json
new file mode 100644
index 0000000..0ef4a4b
--- /dev/null
+++ b/packages/common/tsconfig.json
@@ -0,0 +1,8 @@
+{
+ "extends": "@repo/typescript-config/base.json",
+ "compilerOptions": {
+ "outDir": "dist"
+ },
+ "include": ["src"],
+ "exclude": ["node_modules", "dist"]
+}
\ No newline at end of file
diff --git a/packages/db/package.json b/packages/db/package.json
index 0f215e4..6942eb8 100644
--- a/packages/db/package.json
+++ b/packages/db/package.json
@@ -8,6 +8,6 @@
"prisma": "5.11.0"
},
"exports": {
- "./client": "./index.ts"
+ "./client": "./src/index.ts"
}
}
diff --git a/packages/db/prisma/migrations/20240406192513_init/migration.sql b/packages/db/prisma/migrations/20240406192513_init/migration.sql
new file mode 100644
index 0000000..ab71b36
--- /dev/null
+++ b/packages/db/prisma/migrations/20240406192513_init/migration.sql
@@ -0,0 +1,8 @@
+/*
+ Warnings:
+
+ - Made the column `email` on table `User` required. This step will fail if there are existing NULL values in that column.
+
+*/
+-- AlterTable
+ALTER TABLE "User" ALTER COLUMN "email" SET NOT NULL;
diff --git a/packages/db/prisma/migrations/20240407141903_init/migration.sql b/packages/db/prisma/migrations/20240407141903_init/migration.sql
new file mode 100644
index 0000000..3df300d
--- /dev/null
+++ b/packages/db/prisma/migrations/20240407141903_init/migration.sql
@@ -0,0 +1,19 @@
+/*
+ Warnings:
+
+ - You are about to drop the column `name` on the `Merchant` table. All the data in the column will be lost.
+ - You are about to drop the column `name` on the `User` table. All the data in the column will be lost.
+ - You are about to drop the column `number` on the `User` table. All the data in the column will be lost.
+ - Added the required column `password` to the `Merchant` table without a default value. This is not possible if the table is not empty.
+
+*/
+-- DropIndex
+DROP INDEX "User_number_key";
+
+-- AlterTable
+ALTER TABLE "Merchant" DROP COLUMN "name",
+ADD COLUMN "password" TEXT NOT NULL;
+
+-- AlterTable
+ALTER TABLE "User" DROP COLUMN "name",
+DROP COLUMN "number";
diff --git a/packages/db/prisma/migrations/20240407144353_ini/migration.sql b/packages/db/prisma/migrations/20240407144353_ini/migration.sql
new file mode 100644
index 0000000..b96c586
--- /dev/null
+++ b/packages/db/prisma/migrations/20240407144353_ini/migration.sql
@@ -0,0 +1,11 @@
+/*
+ Warnings:
+
+ - You are about to drop the column `auth_type` on the `Merchant` table. All the data in the column will be lost.
+
+*/
+-- AlterTable
+ALTER TABLE "Merchant" DROP COLUMN "auth_type";
+
+-- DropEnum
+DROP TYPE "AuthType";
diff --git a/packages/db/prisma/migrations/20240409115643_init/migration.sql b/packages/db/prisma/migrations/20240409115643_init/migration.sql
new file mode 100644
index 0000000..f8caabe
--- /dev/null
+++ b/packages/db/prisma/migrations/20240409115643_init/migration.sql
@@ -0,0 +1,33 @@
+-- CreateEnum
+CREATE TYPE "TransactionStatus" AS ENUM ('Pending', 'Processing', 'Failed', 'Succeeded');
+
+-- CreateTable
+CREATE TABLE "Balance" (
+ "id" SERIAL NOT NULL,
+ "userId" INTEGER NOT NULL,
+ "amount" DOUBLE PRECISION NOT NULL,
+
+ CONSTRAINT "Balance_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "OnRampTransaction" (
+ "id" SERIAL NOT NULL,
+ "userID" INTEGER NOT NULL,
+ "amount" DOUBLE PRECISION NOT NULL,
+ "status" "TransactionStatus" NOT NULL,
+ "rampUserId" TEXT,
+ "transactionId" TEXT,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+
+ CONSTRAINT "OnRampTransaction_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateIndex
+CREATE UNIQUE INDEX "Balance_userId_key" ON "Balance"("userId");
+
+-- AddForeignKey
+ALTER TABLE "Balance" ADD CONSTRAINT "Balance_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "OnRampTransaction" ADD CONSTRAINT "OnRampTransaction_userID_fkey" FOREIGN KEY ("userID") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/packages/db/prisma/schema.prisma b/packages/db/prisma/schema.prisma
index 9e4ced4..84cb467 100644
--- a/packages/db/prisma/schema.prisma
+++ b/packages/db/prisma/schema.prisma
@@ -8,21 +8,39 @@ datasource db {
}
model User {
- id Int @id @default(autoincrement())
- email String? @unique
- name String?
- number String @unique
- password String
+ id Int @id @default(autoincrement())
+ email String @unique
+ password String
+ balance Balance[]
+ OnRampTransection OnRampTransaction[]
}
model Merchant {
- id Int @id @default(autoincrement())
- email String @unique
- name String?
- auth_type AuthType
+ id Int @id @default(autoincrement())
+ email String @unique
+ password String
}
-enum AuthType {
- Google
- Github
-}
\ No newline at end of file
+model Balance {
+ id Int @id @default(autoincrement())
+ userId Int @unique
+ amount Float
+ user User @relation(fields: [userId], references: [id])
+}
+
+model OnRampTransaction {
+ id Int @id @default(autoincrement())
+ user User @relation(fields: [userID], references: [id])
+ userID Int
+ amount Float
+ status TransactionStatus
+ rampUserId String?
+ transactionId String?
+ createdAt DateTime @default(now())
+}
+enum TransactionStatus {
+ Pending
+ Processing
+ Failed
+ Succeeded
+}
diff --git a/packages/db/index.ts b/packages/db/src/index.ts
similarity index 100%
rename from packages/db/index.ts
rename to packages/db/src/index.ts
diff --git a/packages/store/package.json b/packages/store/package.json
index b92ae80..c652f65 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"
}
}
diff --git a/packages/store/src/atoms/balance.ts b/packages/store/src/atoms/balance.ts
index 5952b8c..e0fe973 100644
--- a/packages/store/src/atoms/balance.ts
+++ b/packages/store/src/atoms/balance.ts
@@ -1,7 +1,6 @@
-
import { atom } from "recoil";
-export const balanceAtom = atom({
- key: "balance",
+export const balanceAtom = atom({
+ key: 'balance',
default: 0,
})
\ No newline at end of file
diff --git a/packages/store/src/hooks/useBalance.ts b/packages/store/src/hooks/useBalance.ts
index ee84590..4b05f60 100644
--- a/packages/store/src/hooks/useBalance.ts
+++ b/packages/store/src/hooks/useBalance.ts
@@ -1,5 +1,5 @@
import { useRecoilValue } from "recoil"
-import { balanceAtom } from "../atoms/balance"
+import { balanceAtom } from "../atoms/balance";
export const useBalance = () => {
const value = useRecoilValue(balanceAtom);
diff --git a/packages/ui/src/Appbar.tsx b/packages/ui/src/Appbar.tsx
index 905830a..e69de29 100644
--- a/packages/ui/src/Appbar.tsx
+++ b/packages/ui/src/Appbar.tsx
@@ -1,25 +0,0 @@
-import { Button } from "./button";
-
-interface AppbarProps {
- user?: {
- name?: string | null;
- },
- // TODO: can u figure out what the type should be here?
- onSignin: any,
- onSignout: any
-}
-
-export const Appbar = ({
- user,
- onSignin,
- onSignout
-}: AppbarProps) => {
- return
-
- PayTM
-
-
-
-
-
-}
\ No newline at end of file
diff --git a/packages/ui/src/button.tsx b/packages/ui/src/button.tsx
index fdab50d..e69de29 100644
--- a/packages/ui/src/button.tsx
+++ b/packages/ui/src/button.tsx
@@ -1,17 +0,0 @@
-"use client";
-
-import { ReactNode } from "react";
-
-interface ButtonProps {
- children: ReactNode;
- onClick: () => void;
-}
-
-export const Button = ({ onClick, children }: ButtonProps) => {
- return (
-
-
- );
-};
diff --git a/packages/ui/src/card.tsx b/packages/ui/src/card.tsx
index 81ff478..e69de29 100644
--- a/packages/ui/src/card.tsx
+++ b/packages/ui/src/card.tsx
@@ -1,25 +0,0 @@
-export function Card({
- className,
- title,
- children,
- href,
-}: {
- className?: string;
- title: string;
- children: React.ReactNode;
- href: string;
-}): JSX.Element {
- return (
-
-
- {title} ->
-
- {children}
-
- );
-}
diff --git a/packages/ui/src/code.tsx b/packages/ui/src/code.tsx
index 769d971..8b13789 100644
--- a/packages/ui/src/code.tsx
+++ b/packages/ui/src/code.tsx
@@ -1,9 +1 @@
-export function Code({
- children,
- className,
-}: {
- children: React.ReactNode;
- className?: string;
-}): JSX.Element {
- return {children}
;
-}
+