Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hiii #4

Open
wants to merge 6 commits into
base: migration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions apps/bank-webhook/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 2 additions & 0 deletions apps/bank-webhook/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const common = require ("@repo/common/type")
console.log(common.DATA_URL)
8 changes: 8 additions & 0 deletions apps/bank-webhook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@repo/typescript-config/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
61 changes: 57 additions & 4 deletions apps/merchant-app/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -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 }

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}
16 changes: 0 additions & 16 deletions apps/merchant-app/app/api/user/route.ts

This file was deleted.

7 changes: 4 additions & 3 deletions apps/merchant-app/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -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"] });

Expand All @@ -17,9 +17,10 @@ export default function RootLayout({
}): JSX.Element {
return (
<html lang="en">
<Providers>
<Provider>
<body className={inter.className}>{children}</body>
</Providers>
</Provider>

</html>
);
}
25 changes: 17 additions & 8 deletions apps/merchant-app/app/page.tsx
Original file line number Diff line number Diff line change
@@ -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 <div>
hi there {balance}
</div>
export default function(){
const session = useSession()
return(
<>
<div className="bg-red-500 flex flex-row justify-between">
<div>
<button onClick={()=>signIn()}>Signin</button>
</div>
<div>
<button onClick={()=>signOut()}>Log Out</button>
</div>
</div>
{JSON.stringify(session)}
</>
)
}
48 changes: 0 additions & 48 deletions apps/merchant-app/lib/auth.ts

This file was deleted.

19 changes: 11 additions & 8 deletions apps/merchant-app/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"use client"
import { RecoilRoot } from "recoil";
import { SessionProvider } from "next-auth/react";
export const Providers = ({children}: {children: React.ReactNode}) => {
return <RecoilRoot>
<SessionProvider>
{children}
</SessionProvider>
</RecoilRoot>
import { SessionProvider } from "next-auth/react"
import {RecoilRoot} from "recoil"

export default function Provider({children}:any){
return(
<RecoilRoot>
<SessionProvider>
{children}
</SessionProvider>
</RecoilRoot>
)
}
60 changes: 56 additions & 4 deletions apps/user-app/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -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 }
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}
15 changes: 4 additions & 11 deletions apps/user-app/app/api/user/route.ts
Original file line number Diff line number Diff line change
@@ -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,
})
}
8 changes: 2 additions & 6 deletions apps/user-app/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<html lang="en">
<html lang="en">
<Providers>
<body className={inter.className}>{children}</body>
</Providers>
Expand Down
Loading