├── .npmrc ├── apps ├── merchant-app │ ├── src │ │ ├── app │ │ │ ├── globals.css │ │ │ ├── favicon.ico │ │ │ ├── api │ │ │ │ └── auth │ │ │ │ │ └── [...nextauth] │ │ │ │ │ └── route.ts │ │ │ ├── page.tsx │ │ │ └── layout.tsx │ │ ├── lib │ │ │ └── auth.ts │ │ └── components │ │ │ ├── elements │ │ │ └── Providers.tsx │ │ │ └── UI │ │ │ └── Test.tsx │ ├── next.config.mjs │ ├── postcss.config.mjs │ ├── .envExample │ ├── .eslintrc.json │ ├── tailwind.config.ts │ ├── tsconfig.json │ ├── .gitignore │ ├── package.json │ └── README.md └── user-app │ ├── src │ ├── app │ │ ├── globals.css │ │ ├── favicon.ico │ │ ├── api │ │ │ ├── auth │ │ │ │ └── [...nextauth] │ │ │ │ │ └── route.ts │ │ │ ├── user │ │ │ │ └── route.ts │ │ │ └── user.route.ts │ │ ├── page.tsx │ │ └── layout.tsx │ ├── components │ │ ├── elements │ │ │ └── Providers.tsx │ │ └── UI │ │ │ └── Test.tsx │ └── lib │ │ └── auth.ts │ ├── next.config.mjs │ ├── .envExample │ ├── postcss.config.mjs │ ├── .eslintrc.json │ ├── tailwind.config.ts │ ├── tsconfig.json │ ├── .gitignore │ ├── package.json │ └── README.md ├── packages ├── db │ ├── .gitignore │ ├── .envExample │ ├── prisma │ │ ├── migrations │ │ │ ├── migration_lock.toml │ │ │ ├── 20240623161904_init │ │ │ │ └── migration.sql │ │ │ ├── 20240703032535_schema_change │ │ │ │ └── migration.sql │ │ │ ├── 20240715133241_update_schema │ │ │ │ └── migration.sql │ │ │ └── 20240715134731_update_schema │ │ │ │ └── migration.sql │ │ └── schema.prisma │ ├── tsconfig.json │ ├── package.json │ └── src │ │ └── index.ts ├── eslint-config │ ├── README.md │ ├── package.json │ ├── library.js │ ├── next.js │ └── react-internal.js ├── types │ ├── src │ │ └── test.ts │ ├── tsconfig.json │ └── package.json ├── store │ ├── src │ │ ├── atoms │ │ │ └── count.ts │ │ └── hooks │ │ │ └── useCount.ts │ ├── tsconfig.json │ └── package.json ├── ui │ ├── tsconfig.json │ ├── src │ │ ├── code.tsx │ │ ├── button.tsx │ │ ├── card.tsx │ │ └── appbar.tsx │ ├── tsconfig.lint.json │ ├── turbo │ │ └── generators │ │ │ ├── templates │ │ │ └── component.hbs │ │ │ └── config.ts │ ├── .eslintrc.js │ └── package.json └── typescript-config │ ├── package.json │ ├── react-library.json │ ├── nextjs.json │ └── base.json ├── turbo.json ├── package.json ├── .gitignore └── README.md /.npmrc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/merchant-app/src/app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /apps/user-app/src/app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /packages/db/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | # Keep environment variables out of version control 3 | .env 4 | -------------------------------------------------------------------------------- /packages/db/.envExample: -------------------------------------------------------------------------------- 1 | # add a .env file and fill this up 2 | 3 | DATABASE_URL="your database connection string" 4 | -------------------------------------------------------------------------------- /packages/eslint-config/README.md: -------------------------------------------------------------------------------- 1 | # `@turbo/eslint-config` 2 | 3 | Collection of internal eslint configurations. 4 | -------------------------------------------------------------------------------- /apps/user-app/src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfaarghya/wallet-app/main/apps/user-app/src/app/favicon.ico -------------------------------------------------------------------------------- /apps/merchant-app/src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfaarghya/wallet-app/main/apps/merchant-app/src/app/favicon.ico -------------------------------------------------------------------------------- /apps/user-app/next.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = {}; 3 | 4 | export default nextConfig; 5 | -------------------------------------------------------------------------------- /apps/merchant-app/next.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = {}; 3 | 4 | export default nextConfig; 5 | -------------------------------------------------------------------------------- /apps/user-app/.envExample: -------------------------------------------------------------------------------- 1 | # add a .env file and fill this up 2 | 3 | JWT_SECRET=your_twt_secret 4 | NEXTAUTH_URL=http://localhost:3000 5 | -------------------------------------------------------------------------------- /packages/types/src/test.ts: -------------------------------------------------------------------------------- 1 | export interface Test { 2 | name: string; 3 | age: number; 4 | address?: string; 5 | phone?: string; 6 | } 7 | -------------------------------------------------------------------------------- /packages/store/src/atoms/count.ts: -------------------------------------------------------------------------------- 1 | import { atom } from "recoil"; 2 | 3 | export const countAtom = atom({ 4 | key: "countAtom", 5 | default: 111, 6 | }); 7 | -------------------------------------------------------------------------------- /packages/db/prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (i.e. Git) 3 | provider = "postgresql" -------------------------------------------------------------------------------- /apps/merchant-app/postcss.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('postcss-load-config').Config} */ 2 | const config = { 3 | plugins: { 4 | tailwindcss: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /apps/user-app/postcss.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('postcss-load-config').Config} */ 2 | const config = { 3 | plugins: { 4 | tailwindcss: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /packages/db/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@wallet-app/typescript-config/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src"], 7 | "exclude": ["node_modules", "dist"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/store/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@wallet-app/typescript-config/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src"], 7 | "exclude": ["node_modules", "dist"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@wallet-app/typescript-config/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src"], 7 | "exclude": ["node_modules", "dist"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@wallet-app/typescript-config/react-library.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src"], 7 | "exclude": ["node_modules", "dist"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/typescript-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@wallet-app/typescript-config", 3 | "version": "0.0.0", 4 | "private": true, 5 | "license": "MIT", 6 | "publishConfig": { 7 | "access": "public" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/typescript-config/react-library.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "display": "React Library", 4 | "extends": "./base.json", 5 | "compilerOptions": { 6 | "jsx": "react-jsx" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /apps/user-app/src/app/api/auth/[...nextauth]/route.ts: -------------------------------------------------------------------------------- 1 | import NextAuth from "next-auth"; 2 | import { authOptions } from "../../../../lib/auth"; 3 | 4 | const handler = NextAuth(authOptions); 5 | 6 | export { handler as GET, handler as POST }; 7 | -------------------------------------------------------------------------------- /apps/merchant-app/src/app/api/auth/[...nextauth]/route.ts: -------------------------------------------------------------------------------- 1 | import NextAuth from "next-auth"; 2 | import { authOptions } from "../../../../lib/auth"; 3 | 4 | const handler = NextAuth(authOptions); 5 | 6 | export { handler as GET, handler as POST }; 7 | -------------------------------------------------------------------------------- /packages/ui/src/code.tsx: -------------------------------------------------------------------------------- 1 | export function Code({ 2 | children, 3 | className, 4 | }: { 5 | children: React.ReactNode; 6 | className?: string; 7 | }): JSX.Element { 8 | return {children}; 9 | } 10 | -------------------------------------------------------------------------------- /packages/ui/tsconfig.lint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@wallet-app/typescript-config/react-library.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src", "turbo"], 7 | "exclude": ["node_modules", "dist"] 8 | } 9 | -------------------------------------------------------------------------------- /apps/merchant-app/src/app/page.tsx: -------------------------------------------------------------------------------- 1 | import TestUI from "../components/UI/Test"; 2 | 3 | export default function Home() { 4 | return ( 5 | <> 6 |
Hello Merchants
7 | 8 | 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /packages/ui/turbo/generators/templates/component.hbs: -------------------------------------------------------------------------------- 1 | export const {{ pascalCase name }} = ({ children }: { children: React.ReactNode }) => { 2 | return ( 3 |
4 |

{{ pascalCase name }} Component

5 | {children} 6 |
7 | ); 8 | }; 9 | -------------------------------------------------------------------------------- /apps/user-app/.eslintrc.json: -------------------------------------------------------------------------------- 1 | /** @type {import("eslint").Linter.Config} */ 2 | module.exports = { 3 | root: true, 4 | extends: ["@wallet-app/eslint-config/next.js"], 5 | parser: "@typescript-eslint/parser", 6 | parserOptions: { 7 | project: true, 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /apps/merchant-app/.envExample: -------------------------------------------------------------------------------- 1 | # add a .env file and fill this up 2 | 3 | # go to this page to generate -> https://next-auth.js.org/providers/google 4 | 5 | GOOGLE_CLIENT_ID= 6 | GOOGLE_CLIENT_SECRET= 7 | 8 | NEXTAUTH_URL=http://localhost:3001 9 | NEXTAUTH_SECRET=your_secret 10 | -------------------------------------------------------------------------------- /apps/merchant-app/.eslintrc.json: -------------------------------------------------------------------------------- 1 | /** @type {import("eslint").Linter.Config} */ 2 | module.exports = { 3 | root: true, 4 | extends: ["@wallet-app/eslint-config/next.js"], 5 | parser: "@typescript-eslint/parser", 6 | parserOptions: { 7 | project: true, 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /apps/user-app/tailwind.config.ts: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | "./src/**/*.{js,ts,jsx,tsx,mdx}", 5 | "../../packages/ui/src/**/*.{js,ts,jsx,tsx,mdx}", 6 | ], 7 | theme: { 8 | extend: {}, 9 | }, 10 | plugins: [], 11 | }; 12 | -------------------------------------------------------------------------------- /apps/merchant-app/tailwind.config.ts: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | "./src/**/*.{js,ts,jsx,tsx,mdx}", 5 | "../../packages/ui/src/**/*.{js,ts,jsx,tsx,mdx}", 6 | ], 7 | theme: { 8 | extend: {}, 9 | }, 10 | plugins: [], 11 | }; 12 | -------------------------------------------------------------------------------- /apps/merchant-app/src/lib/auth.ts: -------------------------------------------------------------------------------- 1 | import GoogleProvider from "next-auth/providers/google"; 2 | 3 | export const authOptions = { 4 | providers: [ 5 | GoogleProvider({ 6 | clientId: process.env.GOOGLE_CLIENT_ID || "", 7 | clientSecret: process.env.GOOGLE_CLIENT_SECRET || "", 8 | }), 9 | ], 10 | }; 11 | -------------------------------------------------------------------------------- /packages/db/prisma/migrations/20240623161904_init/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "User" ( 3 | "id" SERIAL NOT NULL, 4 | "email" TEXT NOT NULL, 5 | "name" TEXT, 6 | 7 | CONSTRAINT "User_pkey" PRIMARY KEY ("id") 8 | ); 9 | 10 | -- CreateIndex 11 | CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); 12 | -------------------------------------------------------------------------------- /packages/ui/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /** @type {import("eslint").Linter.Config} */ 2 | module.exports = { 3 | root: true, 4 | extends: ["@wallet-app/eslint-config/react-internal.js"], 5 | parser: "@typescript-eslint/parser", 6 | parserOptions: { 7 | project: "./tsconfig.lint.json", 8 | tsconfigRootDir: __dirname, 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /packages/types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@wallet-app/types", 3 | "version": "1.0.0", 4 | "author": "alfaarghya", 5 | "license": "MIT", 6 | "private": true, 7 | "exports": { 8 | "./test": "./src/test.ts" 9 | }, 10 | "devDependencies": { 11 | "@wallet-app/eslint-config": "*", 12 | "@wallet-app/typescript-config": "*" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /apps/user-app/src/app/api/user/route.ts: -------------------------------------------------------------------------------- 1 | import { NextResponse } from "next/server"; 2 | import prisma from "@wallet-app/db/client"; 3 | 4 | export const GET = async () => { 5 | await prisma.user.create({ 6 | data: { 7 | email: "asd", 8 | name: "adsads", 9 | }, 10 | }); 11 | return NextResponse.json({ 12 | message: "hi there", 13 | }); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/typescript-config/nextjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "display": "Next.js", 4 | "extends": "./base.json", 5 | "compilerOptions": { 6 | "plugins": [{ "name": "next" }], 7 | "module": "ESNext", 8 | "moduleResolution": "Bundler", 9 | "allowJs": true, 10 | "jsx": "preserve", 11 | "noEmit": true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /apps/user-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@wallet-app/typescript-config/nextjs.json", 3 | "compilerOptions": { 4 | "plugins": [ 5 | { 6 | "name": "next" 7 | } 8 | ] 9 | }, 10 | "include": [ 11 | "next-env.d.ts", 12 | "next.config.js", 13 | "**/*.ts", 14 | "**/*.tsx", 15 | ".next/types/**/*.ts" 16 | ], 17 | "exclude": ["node_modules"] 18 | } 19 | -------------------------------------------------------------------------------- /apps/merchant-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@wallet-app/typescript-config/nextjs.json", 3 | "compilerOptions": { 4 | "plugins": [ 5 | { 6 | "name": "next" 7 | } 8 | ] 9 | }, 10 | "include": [ 11 | "next-env.d.ts", 12 | "next.config.js", 13 | "**/*.ts", 14 | "**/*.tsx", 15 | ".next/types/**/*.ts" 16 | ], 17 | "exclude": ["node_modules"] 18 | } 19 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turbo.build/schema.json", 3 | "tasks": { 4 | "build": { 5 | "dependsOn": ["^build"], 6 | "inputs": ["$TURBO_DEFAULT$", ".env*"], 7 | "outputs": [".next/**", "!.next/cache/**"] 8 | }, 9 | "lint": { 10 | "dependsOn": ["^lint"] 11 | }, 12 | "dev": { 13 | "cache": false, 14 | "persistent": true 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/store/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@wallet-app/store", 3 | "version": "1.0.0", 4 | "author": "alfaarghya", 5 | "license": "MIT", 6 | "private": true, 7 | "exports": { 8 | "./useCount": "./src/hooks/useCount.ts" 9 | }, 10 | "dependencies": { 11 | "recoil": "^0.7.7" 12 | }, 13 | "devDependencies": { 14 | "@wallet-app/eslint-config": "*", 15 | "@wallet-app/typescript-config": "*" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /apps/user-app/src/components/elements/Providers.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { SessionProvider } from "next-auth/react"; 4 | import { ReactNode } from "react"; 5 | import { RecoilRoot } from "recoil"; 6 | 7 | const Providers = ({ children }: { children: ReactNode }) => { 8 | return ( 9 | 10 | {children}; 11 | 12 | ); 13 | }; 14 | 15 | export default Providers; 16 | -------------------------------------------------------------------------------- /apps/merchant-app/src/components/elements/Providers.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { SessionProvider } from "next-auth/react"; 4 | import { ReactNode } from "react"; 5 | import { RecoilRoot } from "recoil"; 6 | 7 | const Providers = ({ children }: { children: ReactNode }) => { 8 | return ( 9 | 10 | {children}; 11 | 12 | ); 13 | }; 14 | 15 | export default Providers; 16 | -------------------------------------------------------------------------------- /packages/db/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@wallet-app/db", 3 | "version": "1.0.0", 4 | "author": "alfaarghya", 5 | "license": "MIT", 6 | "private": true, 7 | "exports": { 8 | "./client": "./src/index.ts" 9 | }, 10 | "devDependencies": { 11 | "@wallet-app/eslint-config": "*", 12 | "@wallet-app/typescript-config": "*", 13 | "prisma": "^5.16.1" 14 | }, 15 | "dependencies": { 16 | "@prisma/client": "^5.15.1", 17 | "prisma": "^5.16.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /apps/user-app/src/app/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | import { Appbar } from "@wallet-app/ui/appbar"; 3 | import TestUI from "../components/UI/Test"; 4 | import { signIn, signOut, useSession } from "next-auth/react"; 5 | 6 | export default function Home() { 7 | const session = useSession(); 8 | return ( 9 | <> 10 | 11 |
Hello Users
12 | 13 | 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /packages/db/src/index.ts: -------------------------------------------------------------------------------- 1 | import { PrismaClient } from "@prisma/client"; 2 | 3 | const prismaClientSingleton = () => { 4 | return new PrismaClient(); 5 | }; 6 | 7 | declare global { 8 | var prismaGlobal: undefined | ReturnType; 9 | } 10 | 11 | const prisma: ReturnType = 12 | globalThis.prismaGlobal ?? prismaClientSingleton(); 13 | 14 | export default prisma; 15 | 16 | if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma; 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wallet-app", 3 | "private": true, 4 | "scripts": { 5 | "build": "turbo build", 6 | "dev": "turbo dev", 7 | "lint": "turbo lint", 8 | "format": "prettier --write \"**/*.{ts,tsx,md}\"" 9 | }, 10 | "devDependencies": { 11 | "prettier": "^3.2.5", 12 | "turbo": "^2.0.4", 13 | "typescript": "^5.4.5" 14 | }, 15 | "engines": { 16 | "node": ">=18" 17 | }, 18 | "packageManager": "yarn@1.22.22", 19 | "workspaces": [ 20 | "apps/*", 21 | "packages/*" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /packages/store/src/hooks/useCount.ts: -------------------------------------------------------------------------------- 1 | import { useRecoilState, useRecoilValue, useSetRecoilState } from "recoil"; 2 | import { countAtom } from "../atoms/count"; 3 | 4 | export const useCountValue = () => { 5 | const value = useRecoilValue(countAtom); 6 | return value; 7 | }; 8 | export const useSetCountState = () => { 9 | const setValue = useSetRecoilState(countAtom); 10 | return setValue; 11 | }; 12 | export const useCountState = () => { 13 | const [value, setValue] = useRecoilState(countAtom); 14 | return { value, setValue }; 15 | }; 16 | -------------------------------------------------------------------------------- /apps/user-app/src/app/api/user.route.ts: -------------------------------------------------------------------------------- 1 | import { getServerSession } from "next-auth"; 2 | import { NextResponse } from "next/server"; 3 | import { authOptions } from "../../lib/auth"; 4 | 5 | export const GET = async () => { 6 | const session = await getServerSession(authOptions); 7 | if (session.user) { 8 | return NextResponse.json({ 9 | user: session.user, 10 | }); 11 | } 12 | return NextResponse.json( 13 | { 14 | message: "You are not logged in", 15 | }, 16 | { 17 | status: 403, 18 | } 19 | ); 20 | }; 21 | -------------------------------------------------------------------------------- /packages/eslint-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@wallet-app/eslint-config", 3 | "version": "0.0.0", 4 | "private": true, 5 | "files": [ 6 | "library.js", 7 | "next.js", 8 | "react-internal.js" 9 | ], 10 | "devDependencies": { 11 | "@vercel/style-guide": "^5.2.0", 12 | "eslint-config-turbo": "^2.0.0", 13 | "eslint-config-prettier": "^9.1.0", 14 | "eslint-plugin-only-warn": "^1.1.0", 15 | "@typescript-eslint/parser": "^7.1.0", 16 | "@typescript-eslint/eslint-plugin": "^7.1.0", 17 | "typescript": "^5.3.3" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/ui/src/button.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { ReactNode } from "react"; 4 | 5 | interface ButtonProps { 6 | children: ReactNode; 7 | onClick: () => void; 8 | } 9 | 10 | export const Button = ({ onClick, children }: ButtonProps) => { 11 | return ( 12 | 19 | ); 20 | }; 21 | -------------------------------------------------------------------------------- /apps/user-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # Dependencies 4 | node_modules 5 | .pnp 6 | .pnp.js 7 | 8 | # Local env files 9 | .env 10 | .env.local 11 | .env.development.local 12 | .env.test.local 13 | .env.production.local 14 | 15 | # Testing 16 | coverage 17 | 18 | # Turbo 19 | .turbo 20 | 21 | # Vercel 22 | .vercel 23 | 24 | # Build Outputs 25 | .next/ 26 | out/ 27 | build 28 | dist 29 | 30 | 31 | # Debug 32 | npm-debug.log* 33 | yarn-debug.log* 34 | yarn-error.log* 35 | 36 | # Misc 37 | .DS_Store 38 | *.pem 39 | -------------------------------------------------------------------------------- /apps/merchant-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /packages/ui/src/card.tsx: -------------------------------------------------------------------------------- 1 | export function Card({ 2 | className, 3 | title, 4 | children, 5 | href, 6 | }: { 7 | className?: string; 8 | title: string; 9 | children: React.ReactNode; 10 | href: string; 11 | }): JSX.Element { 12 | return ( 13 | 19 |

20 | {title} -> 21 |

22 |

{children}

23 |
24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /packages/typescript-config/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "display": "Default", 4 | "compilerOptions": { 5 | "declaration": true, 6 | "declarationMap": true, 7 | "esModuleInterop": true, 8 | "incremental": false, 9 | "isolatedModules": true, 10 | "lib": ["es2022", "DOM", "DOM.Iterable"], 11 | "module": "NodeNext", 12 | "moduleDetection": "force", 13 | "moduleResolution": "NodeNext", 14 | "noUncheckedIndexedAccess": true, 15 | "resolveJsonModule": true, 16 | "skipLibCheck": true, 17 | "strict": true, 18 | "target": "ES2022" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /apps/user-app/src/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from "next"; 2 | import { Inter } from "next/font/google"; 3 | import "./globals.css"; 4 | import Providers from "../components/elements/Providers"; 5 | 6 | const inter = Inter({ subsets: ["latin"] }); 7 | 8 | export const metadata: Metadata = { 9 | title: "Wallet-App || User App", 10 | description: "Generated by create next app", 11 | }; 12 | 13 | export default function RootLayout({ 14 | children, 15 | }: Readonly<{ 16 | children: React.ReactNode; 17 | }>) { 18 | return ( 19 | 20 | 21 | {children} 22 | 23 | 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /apps/merchant-app/src/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from "next"; 2 | import { Inter } from "next/font/google"; 3 | import "./globals.css"; 4 | import Providers from "../components/elements/Providers"; 5 | 6 | const inter = Inter({ subsets: ["latin"] }); 7 | 8 | export const metadata: Metadata = { 9 | title: "Wallet-App || Merchant App", 10 | description: "Generated by create next app", 11 | }; 12 | 13 | export default function RootLayout({ 14 | children, 15 | }: Readonly<{ 16 | children: React.ReactNode; 17 | }>) { 18 | return ( 19 | 20 | 21 | {children} 22 | 23 | 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /packages/ui/src/appbar.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { Button } from "./button"; 4 | 5 | interface AppbarProps { 6 | user?: { 7 | name?: string | null; 8 | }; 9 | // TODO: can u figure out what the type should be here? 10 | onSignin: any; 11 | onSignout: any; 12 | } 13 | 14 | export const Appbar = ({ user, onSignin, onSignout }: AppbarProps) => { 15 | return ( 16 |
17 |
PayTM
18 |
19 | 22 |
23 |
24 | ); 25 | }; 26 | -------------------------------------------------------------------------------- /packages/eslint-config/library.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require("node:path"); 2 | 3 | const project = resolve(process.cwd(), "tsconfig.json"); 4 | 5 | /** @type {import("eslint").Linter.Config} */ 6 | module.exports = { 7 | extends: ["eslint:recommended", "prettier", "turbo"], 8 | plugins: ["only-warn"], 9 | globals: { 10 | React: true, 11 | JSX: true, 12 | }, 13 | env: { 14 | node: true, 15 | }, 16 | settings: { 17 | "import/resolver": { 18 | typescript: { 19 | project, 20 | }, 21 | }, 22 | }, 23 | ignorePatterns: [ 24 | // Ignore dotfiles 25 | ".*.js", 26 | "node_modules/", 27 | "dist/", 28 | ], 29 | overrides: [ 30 | { 31 | files: ["*.js?(x)", "*.ts?(x)"], 32 | }, 33 | ], 34 | }; 35 | -------------------------------------------------------------------------------- /packages/eslint-config/next.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require("node:path"); 2 | 3 | const project = resolve(process.cwd(), "tsconfig.json"); 4 | 5 | /** @type {import("eslint").Linter.Config} */ 6 | module.exports = { 7 | extends: [ 8 | "eslint:recommended", 9 | "prettier", 10 | require.resolve("@vercel/style-guide/eslint/next"), 11 | "turbo", 12 | ], 13 | globals: { 14 | React: true, 15 | JSX: true, 16 | }, 17 | env: { 18 | node: true, 19 | browser: true, 20 | }, 21 | plugins: ["only-warn"], 22 | settings: { 23 | "import/resolver": { 24 | typescript: { 25 | project, 26 | }, 27 | }, 28 | }, 29 | ignorePatterns: [ 30 | // Ignore dotfiles 31 | ".*.js", 32 | "node_modules/", 33 | ], 34 | overrides: [{ files: ["*.js?(x)", "*.ts?(x)"] }], 35 | }; 36 | -------------------------------------------------------------------------------- /apps/merchant-app/src/components/UI/Test.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | import React from "react"; 3 | import { Test } from "@wallet-app/types/test"; 4 | import { useCountState, useCountValue } from "@wallet-app/store/useCount"; 5 | import { SetterOrUpdater } from "recoil"; 6 | 7 | const TestUI = () => { 8 | const abc: Test = { 9 | name: "alfaarghya_Merchant", 10 | age: 31, 11 | }; 12 | const { 13 | value, 14 | setValue, 15 | }: { value: number; setValue: SetterOrUpdater } = useCountState(); 16 | return ( 17 |
18 |
CountUi {value}
19 | 25 |
{abc.name}
26 |
27 | ); 28 | }; 29 | 30 | export default TestUI; 31 | -------------------------------------------------------------------------------- /packages/ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@wallet-app/ui", 3 | "version": "0.0.0", 4 | "private": true, 5 | "exports": { 6 | "./button": "./src/button.tsx", 7 | "./card": "./src/card.tsx", 8 | "./code": "./src/code.tsx", 9 | "./appbar": "./src/appbar.tsx" 10 | }, 11 | "scripts": { 12 | "lint": "eslint . --max-warnings 0", 13 | "generate:component": "turbo gen react-component" 14 | }, 15 | "devDependencies": { 16 | "@wallet-app/eslint-config": "*", 17 | "@wallet-app/typescript-config": "*", 18 | "@turbo/gen": "^1.12.4", 19 | "@types/node": "^20.11.24", 20 | "@types/eslint": "^8.56.5", 21 | "@types/react": "^18.2.61", 22 | "@types/react-dom": "^18.2.19", 23 | "eslint": "^8.57.0", 24 | "typescript": "^5.3.3" 25 | }, 26 | "dependencies": { 27 | "react": "^18.2.0" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /apps/user-app/src/components/UI/Test.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | import React from "react"; 3 | import { Test } from "@wallet-app/types/test"; 4 | import { useCountState, useCountValue } from "@wallet-app/store/useCount"; 5 | import { SetterOrUpdater } from "recoil"; 6 | 7 | const TestUI = () => { 8 | const { 9 | value, 10 | setValue, 11 | }: { value: number; setValue: SetterOrUpdater } = useCountState(); 12 | // const count = useCountValue(); 13 | const abc: Test = { 14 | name: "alfaarghya", 15 | age: 21, 16 | }; 17 | return ( 18 |
19 |
CountUi {value}
20 | 26 |
{abc.name}
27 |
28 | ); 29 | }; 30 | 31 | export default TestUI; 32 | -------------------------------------------------------------------------------- /packages/eslint-config/react-internal.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require("node:path"); 2 | 3 | const project = resolve(process.cwd(), "tsconfig.json"); 4 | 5 | /* 6 | * This is a custom ESLint configuration for use with 7 | * internal (bundled by their consumer) libraries 8 | * that utilize React. 9 | */ 10 | 11 | /** @type {import("eslint").Linter.Config} */ 12 | module.exports = { 13 | extends: ["eslint:recommended", "prettier", "turbo"], 14 | plugins: ["only-warn"], 15 | globals: { 16 | React: true, 17 | JSX: true, 18 | }, 19 | env: { 20 | browser: true, 21 | }, 22 | settings: { 23 | "import/resolver": { 24 | typescript: { 25 | project, 26 | }, 27 | }, 28 | }, 29 | ignorePatterns: [ 30 | // Ignore dotfiles 31 | ".*.js", 32 | "node_modules/", 33 | "dist/", 34 | ], 35 | overrides: [ 36 | // Force ESLint to detect .tsx files 37 | { files: ["*.js?(x)", "*.ts?(x)"] }, 38 | ], 39 | }; 40 | -------------------------------------------------------------------------------- /apps/merchant-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@wallet-app/merchant-app", 3 | "version": "1.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev --turbo --port 3001", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@types/bcrypt": "^5.0.2", 13 | "@wallet-app/store": "*", 14 | "@wallet-app/ui": "*", 15 | "bcrypt": "^5.1.1", 16 | "next": "14.2.4", 17 | "next-auth": "^4.24.7", 18 | "react": "^18", 19 | "react-dom": "^18", 20 | "recoil": "^0.7.7" 21 | }, 22 | "devDependencies": { 23 | "@types/node": "^20", 24 | "@types/react": "^18", 25 | "@types/react-dom": "^18", 26 | "@wallet-app/eslint-config": "*", 27 | "@wallet-app/types": "*", 28 | "@wallet-app/typescript-config": "*", 29 | "eslint": "^8", 30 | "eslint-config-next": "14.2.4", 31 | "postcss": "^8", 32 | "tailwindcss": "^3.4.1", 33 | "typescript": "^5" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /apps/user-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@wallet-app/user-app", 3 | "version": "1.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev --turbo --port 3000", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@types/bcrypt": "^5.0.2", 13 | "@wallet-app/db": "*", 14 | "@wallet-app/store": "*", 15 | "@wallet-app/ui": "*", 16 | "bcrypt": "^5.1.1", 17 | "next": "14.2.4", 18 | "next-auth": "^4.24.7", 19 | "react": "^18", 20 | "react-dom": "^18", 21 | "recoil": "^0.7.7" 22 | }, 23 | "devDependencies": { 24 | "@types/node": "^20", 25 | "@types/react": "^18", 26 | "@types/react-dom": "^18", 27 | "@wallet-app/eslint-config": "*", 28 | "@wallet-app/types": "*", 29 | "@wallet-app/typescript-config": "*", 30 | "eslint": "^8", 31 | "eslint-config-next": "14.2.4", 32 | "postcss": "^8", 33 | "tailwindcss": "^3.4.1", 34 | "typescript": "^5" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/ui/turbo/generators/config.ts: -------------------------------------------------------------------------------- 1 | import type { PlopTypes } from "@turbo/gen"; 2 | 3 | // Learn more about Turborepo Generators at https://turbo.build/repo/docs/core-concepts/monorepos/code-generation 4 | 5 | export default function generator(plop: PlopTypes.NodePlopAPI): void { 6 | // A simple generator to add a new React component to the internal UI library 7 | plop.setGenerator("react-component", { 8 | description: "Adds a new react component", 9 | prompts: [ 10 | { 11 | type: "input", 12 | name: "name", 13 | message: "What is the name of the component?", 14 | }, 15 | ], 16 | actions: [ 17 | { 18 | type: "add", 19 | path: "src/{{kebabCase name}}.tsx", 20 | templateFile: "templates/component.hbs", 21 | }, 22 | { 23 | type: "append", 24 | path: "package.json", 25 | pattern: /"exports": {(?)/g, 26 | template: ' "./{{kebabCase name}}": "./src/{{kebabCase name}}.tsx",', 27 | }, 28 | ], 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /packages/db/prisma/migrations/20240703032535_schema_change/migration.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Warnings: 3 | 4 | - A unique constraint covering the columns `[number]` on the table `User` will be added. If there are existing duplicate values, this will fail. 5 | - Added the required column `number` to the `User` table without a default value. This is not possible if the table is not empty. 6 | - Added the required column `password` to the `User` table without a default value. This is not possible if the table is not empty. 7 | 8 | */ 9 | -- CreateEnum 10 | CREATE TYPE "AuthType" AS ENUM ('Google', 'Github'); 11 | 12 | -- AlterTable 13 | ALTER TABLE "User" ADD COLUMN "number" TEXT NOT NULL, 14 | ADD COLUMN "password" TEXT NOT NULL, 15 | ALTER COLUMN "email" DROP NOT NULL; 16 | 17 | -- CreateTable 18 | CREATE TABLE "Merchant" ( 19 | "id" SERIAL NOT NULL, 20 | "email" TEXT NOT NULL, 21 | "name" TEXT, 22 | "auth_type" "AuthType" NOT NULL, 23 | 24 | CONSTRAINT "Merchant_pkey" PRIMARY KEY ("id") 25 | ); 26 | 27 | -- CreateIndex 28 | CREATE UNIQUE INDEX "Merchant_email_key" ON "Merchant"("email"); 29 | 30 | -- CreateIndex 31 | CREATE UNIQUE INDEX "User_number_key" ON "User"("number"); 32 | -------------------------------------------------------------------------------- /packages/db/prisma/migrations/20240715133241_update_schema/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateEnum 2 | CREATE TYPE "OnRampStatus" AS ENUM ('Success', 'Failure', 'Processing'); 3 | 4 | -- CreateTable 5 | CREATE TABLE "OnRampTransaction" ( 6 | "id" SERIAL NOT NULL, 7 | "status" "OnRampStatus" NOT NULL, 8 | "token" TEXT NOT NULL, 9 | "provider" TEXT NOT NULL, 10 | "amount" INTEGER NOT NULL, 11 | "startTime" TIMESTAMP(3) NOT NULL, 12 | "userId" INTEGER NOT NULL, 13 | 14 | CONSTRAINT "OnRampTransaction_pkey" PRIMARY KEY ("id") 15 | ); 16 | 17 | -- CreateTable 18 | CREATE TABLE "Balance" ( 19 | "id" SERIAL NOT NULL, 20 | "userId" INTEGER NOT NULL, 21 | "amount" INTEGER NOT NULL, 22 | "locked" INTEGER NOT NULL, 23 | 24 | CONSTRAINT "Balance_pkey" PRIMARY KEY ("id") 25 | ); 26 | 27 | -- CreateIndex 28 | CREATE UNIQUE INDEX "OnRampTransaction_token_key" ON "OnRampTransaction"("token"); 29 | 30 | -- CreateIndex 31 | CREATE UNIQUE INDEX "Balance_userId_key" ON "Balance"("userId"); 32 | 33 | -- AddForeignKey 34 | ALTER TABLE "OnRampTransaction" ADD CONSTRAINT "OnRampTransaction_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; 35 | 36 | -- AddForeignKey 37 | ALTER TABLE "Balance" ADD CONSTRAINT "Balance_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; 38 | -------------------------------------------------------------------------------- /apps/user-app/README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). 2 | 3 | ## Getting Started 4 | 5 | First, run the development server: 6 | 7 | ```bash 8 | npm run dev 9 | # or 10 | yarn dev 11 | # or 12 | pnpm dev 13 | # or 14 | bun dev 15 | ``` 16 | 17 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 18 | 19 | You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. 20 | 21 | This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. 22 | 23 | ## Learn More 24 | 25 | To learn more about Next.js, take a look at the following resources: 26 | 27 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 28 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 29 | 30 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 31 | 32 | ## Deploy on Vercel 33 | 34 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 35 | 36 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 37 | -------------------------------------------------------------------------------- /apps/merchant-app/README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). 2 | 3 | ## Getting Started 4 | 5 | First, run the development server: 6 | 7 | ```bash 8 | npm run dev 9 | # or 10 | yarn dev 11 | # or 12 | pnpm dev 13 | # or 14 | bun dev 15 | ``` 16 | 17 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 18 | 19 | You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. 20 | 21 | This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. 22 | 23 | ## Learn More 24 | 25 | To learn more about Next.js, take a look at the following resources: 26 | 27 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 28 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 29 | 30 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 31 | 32 | ## Deploy on Vercel 33 | 34 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 35 | 36 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 37 | -------------------------------------------------------------------------------- /packages/db/prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | // This is your Prisma schema file, 2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema 3 | 4 | // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? 5 | // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init 6 | 7 | generator client { 8 | provider = "prisma-client-js" 9 | } 10 | 11 | datasource db { 12 | provider = "postgresql" 13 | url = env("DATABASE_URL") 14 | } 15 | 16 | model User { 17 | id String @id @default(uuid()) 18 | email String? @unique 19 | name String? 20 | number String @unique 21 | password String 22 | OnRampTransaction OnRampTransaction[] 23 | Balance Balance[] 24 | } 25 | 26 | model Merchant { 27 | id String @id @default(uuid()) 28 | email String @unique 29 | name String? 30 | auth_type AuthType 31 | } 32 | 33 | model OnRampTransaction { 34 | id String @id @default(uuid()) 35 | status OnRampStatus 36 | token String @unique 37 | provider String 38 | amount Int 39 | startTime DateTime 40 | userId String 41 | user User @relation(fields: [userId], references: [id]) 42 | } 43 | 44 | model Balance { 45 | id Int @id @default(autoincrement()) 46 | userId String @unique 47 | amount Int 48 | locked Int 49 | user User @relation(fields: [userId], references: [id]) 50 | } 51 | 52 | enum AuthType { 53 | Google 54 | Github 55 | } 56 | 57 | enum OnRampStatus { 58 | Success 59 | Failure 60 | Processing 61 | } 62 | -------------------------------------------------------------------------------- /packages/db/prisma/migrations/20240715134731_update_schema/migration.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Warnings: 3 | 4 | - The primary key for the `Merchant` table will be changed. If it partially fails, the table could be left without primary key constraint. 5 | - The primary key for the `OnRampTransaction` table will be changed. If it partially fails, the table could be left without primary key constraint. 6 | - The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint. 7 | 8 | */ 9 | -- DropForeignKey 10 | ALTER TABLE "Balance" DROP CONSTRAINT "Balance_userId_fkey"; 11 | 12 | -- DropForeignKey 13 | ALTER TABLE "OnRampTransaction" DROP CONSTRAINT "OnRampTransaction_userId_fkey"; 14 | 15 | -- AlterTable 16 | ALTER TABLE "Balance" ALTER COLUMN "userId" SET DATA TYPE TEXT; 17 | 18 | -- AlterTable 19 | ALTER TABLE "Merchant" DROP CONSTRAINT "Merchant_pkey", 20 | ALTER COLUMN "id" DROP DEFAULT, 21 | ALTER COLUMN "id" SET DATA TYPE TEXT, 22 | ADD CONSTRAINT "Merchant_pkey" PRIMARY KEY ("id"); 23 | DROP SEQUENCE "Merchant_id_seq"; 24 | 25 | -- AlterTable 26 | ALTER TABLE "OnRampTransaction" DROP CONSTRAINT "OnRampTransaction_pkey", 27 | ALTER COLUMN "id" DROP DEFAULT, 28 | ALTER COLUMN "id" SET DATA TYPE TEXT, 29 | ALTER COLUMN "userId" SET DATA TYPE TEXT, 30 | ADD CONSTRAINT "OnRampTransaction_pkey" PRIMARY KEY ("id"); 31 | DROP SEQUENCE "OnRampTransaction_id_seq"; 32 | 33 | -- AlterTable 34 | ALTER TABLE "User" DROP CONSTRAINT "User_pkey", 35 | ALTER COLUMN "id" DROP DEFAULT, 36 | ALTER COLUMN "id" SET DATA TYPE TEXT, 37 | ADD CONSTRAINT "User_pkey" PRIMARY KEY ("id"); 38 | DROP SEQUENCE "User_id_seq"; 39 | 40 | -- AddForeignKey 41 | ALTER TABLE "OnRampTransaction" ADD CONSTRAINT "OnRampTransaction_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; 42 | 43 | -- AddForeignKey 44 | ALTER TABLE "Balance" ADD CONSTRAINT "Balance_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; 45 | -------------------------------------------------------------------------------- /apps/user-app/src/lib/auth.ts: -------------------------------------------------------------------------------- 1 | import prisma from "@wallet-app/db/client"; 2 | import CredentialsProvider from "next-auth/providers/credentials"; 3 | import bcrypt from "bcrypt"; 4 | 5 | export const authOptions = { 6 | providers: [ 7 | CredentialsProvider({ 8 | name: "Credentials", 9 | credentials: { 10 | phone: { 11 | label: "Phone number", 12 | type: "text", 13 | placeholder: "1231231231", 14 | }, 15 | password: { label: "Password", type: "password" }, 16 | }, 17 | // TODO: User credentials type from next-aut 18 | async authorize(credentials: any) { 19 | // Do zod validation, OTP validation here 20 | const hashedPassword = await bcrypt.hash(credentials.password, 10); 21 | const existingUser = await prisma.user.findFirst({ 22 | where: { 23 | number: credentials.phone, 24 | }, 25 | }); 26 | 27 | if (existingUser) { 28 | const passwordValidation = await bcrypt.compare( 29 | credentials.password, 30 | existingUser.password 31 | ); 32 | if (passwordValidation) { 33 | return { 34 | id: existingUser.id.toString(), 35 | name: existingUser.name, 36 | email: existingUser.number, 37 | }; 38 | } 39 | return null; 40 | } 41 | 42 | try { 43 | const user = await prisma.user.create({ 44 | data: { 45 | number: credentials.phone, 46 | password: hashedPassword, 47 | }, 48 | }); 49 | 50 | return { 51 | id: user.id.toString(), 52 | name: user.name, 53 | email: user.number, 54 | }; 55 | } catch (e) { 56 | console.error(e); 57 | } 58 | 59 | return null; 60 | }, 61 | }), 62 | ], 63 | secret: process.env.JWT_SECRET || "secret", 64 | callbacks: { 65 | // TODO: can u fix the type here? Using any is bad 66 | async session({ token, session }: any) { 67 | session.user.id = token.sub; 68 | 69 | return session; 70 | }, 71 | }, 72 | }; 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Hello World 2 | 3 | # Turborepo starter 4 | 5 | This is an official starter Turborepo. 6 | 7 | ## Using this example 8 | 9 | Run the following command: 10 | 11 | ```sh 12 | npx create-turbo@latest 13 | ``` 14 | 15 | ## What's inside? 16 | 17 | This Turborepo includes the following packages/apps: 18 | 19 | ### Apps and Packages 20 | 21 | - `docs`: a [Next.js](https://nextjs.org/) app 22 | - `web`: another [Next.js](https://nextjs.org/) app 23 | - `@wallet-app/ui`: a stub React component library shared by both `web` and `docs` applications 24 | - `@wallet-app/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`) 25 | - `@wallet-app/typescript-config`: `tsconfig.json`s used throughout the monorepo 26 | 27 | Each package/app is 100% [TypeScript](https://www.typescriptlang.org/). 28 | 29 | ### Utilities 30 | 31 | This Turborepo has some additional tools already setup for you: 32 | 33 | - [TypeScript](https://www.typescriptlang.org/) for static type checking 34 | - [ESLint](https://eslint.org/) for code linting 35 | - [Prettier](https://prettier.io) for code formatting 36 | 37 | ### Build 38 | 39 | To build all apps and packages, run the following command: 40 | 41 | ``` 42 | cd my-turborepo 43 | pnpm build 44 | ``` 45 | 46 | ### Develop 47 | 48 | To develop all apps and packages, run the following command: 49 | 50 | ``` 51 | cd my-turborepo 52 | pnpm dev 53 | ``` 54 | 55 | ### Remote Caching 56 | 57 | Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines. 58 | 59 | By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup), then enter the following commands: 60 | 61 | ``` 62 | cd my-turborepo 63 | npx turbo login 64 | ``` 65 | 66 | This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview). 67 | 68 | Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo: 69 | 70 | ``` 71 | npx turbo link 72 | ``` 73 | 74 | ## Useful Links 75 | 76 | Learn more about the power of Turborepo: 77 | 78 | - [Tasks](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks) 79 | - [Caching](https://turbo.build/repo/docs/core-concepts/caching) 80 | - [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) 81 | - [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering) 82 | - [Configuration Options](https://turbo.build/repo/docs/reference/configuration) 83 | - [CLI Usage](https://turbo.build/repo/docs/reference/command-line-reference) 84 | --------------------------------------------------------------------------------