Skip to content

Commit

Permalink
feat: ✨ adding sign up support for new users
Browse files Browse the repository at this point in the history
  • Loading branch information
WasiqB committed Jan 1, 2025
1 parent c483f22 commit b6d08e5
Show file tree
Hide file tree
Showing 12 changed files with 891 additions and 214 deletions.
6 changes: 4 additions & 2 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
"react-dom": "^19.0"
},
"dependencies": {
"@next/third-parties": "^15.1.2",
"@next/third-parties": "^15.1.3",
"@tanstack/react-table": "^8.20.6",
"@ultra-reporter/analytics": "workspace:*",
"@ultra-reporter/feature-toggle": "workspace:*",
"@ultra-reporter/logger": "workspace:*",
"@ultra-reporter/supabase": "workspace:*",
"@ultra-reporter/ui": "workspace:*",
"@ultra-reporter/utils": "workspace:*",
"lucide-react": "^0.469.0",
"next": "15.1.2"
"next": "15.1.3"
},
"devDependencies": {
"@types/react": "^19.0.2",
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,32 @@
},
"devDependencies": {
"@eslint/compat": "^1.2.4",
"@next/eslint-plugin-next": "^15.1.2",
"@next/eslint-plugin-next": "^15.1.3",
"@release-it-plugins/lerna-changelog": "^7.0.0",
"@stylistic/eslint-plugin-js": "^2.12.1",
"@stylistic/eslint-plugin-ts": "^2.12.1",
"@types/node": "^22.10.2",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"@types/node": "^22.10.3",
"@typescript-eslint/eslint-plugin": "^8.19.0",
"@typescript-eslint/parser": "^8.19.0",
"@vercel/style-guide": "^6.0.0",
"eslint": "^9.17.0",
"eslint-config-next": "15.1.2",
"eslint-config-next": "15.1.3",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "2.3.3",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.14.0",
"husky": "^9.1.7",
"lerna-changelog": "^2.2.0",
"lint-staged": "^15.2.11",
"lint-staged": "^15.3.0",
"prettier": "^3.4.2",
"prettier-plugin-organize-imports": "^4.1.0",
"prettier-plugin-tailwindcss": "^0.6.9",
"release-it": "^17.10.0",
"release-it": "^17.11.0",
"release-it-pnpm": "^4.6.3",
"turbo": "^2.3.3",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.1"
"typescript-eslint": "^8.19.0"
},
"lint-staged": {
"**/*.{ts,tsx}": [
Expand Down
53 changes: 34 additions & 19 deletions packages/db/src/schema/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,45 @@ generator client {
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
provider = "postgresql"
url = env("DATABASE_URL")
relationMode = "prisma"
}

model User {
id String @id @default(cuid())
user_name String
email String
provider String
model TestResultData {
id String @id @default(cuid())
suite_name String
test_name String
class_name String
method_name String
is_config Boolean
tags String[]
parameters String[]
status String
exception_id String
attachment_id String
started_at DateTime
finished_at DateTime
duration Float
created_at DateTime @default(now())
updated_at DateTime @updatedAt
exception TestException? @relation(fields: [exception_id], references: [id])
LoginSession LoginSession[]
}
attachment TestLog? @relation(fields: [attachment_id], references: [id])
model LoginSession {
id String @id @default(cuid())
user_id String
last_login_at DateTime @default(now())
created_at DateTime @default(now())
updated_at DateTime @updatedAt
@@index([exception_id])
@@index([attachment_id])
}

user User @relation(fields: [user_id], references: [id])
model TestLog {
id String @id @default(cuid())
line String
TestResultData TestResultData[]
}

@@index([user_id])
model TestException {
id String @id @default(cuid())
class_name String
message String
stack_trace String[]
TestResultData TestResultData[]
}
2 changes: 1 addition & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"pino": "^9.5.0"
"pino": "^9.6.0"
},
"devDependencies": {
"@ultra-reporter/typescript-config": "workspace:*"
Expand Down
28 changes: 28 additions & 0 deletions packages/supabase/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@ultra-reporter/supabase",
"description": "Ultra Reporter Supabase integration",
"version": "0.6.0",
"private": true,
"scripts": {
"lint": "eslint . --max-warnings 0"
},
"exports": {
"./client": "./src/client.ts",
"./server": "./src/server.ts",
"./middleware": "./src/middleware.ts"
},
"devDependencies": {
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@ultra-reporter/typescript-config": "workspace:*"
},
"peerDependencies": {
"react": "^19.0",
"react-dom": "^19.0"
},
"dependencies": {
"@supabase/ssr": "latest",
"@supabase/supabase-js": "latest",
"next": "15.1.3"
}
}
8 changes: 8 additions & 0 deletions packages/supabase/src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createBrowserClient } from '@supabase/ssr';

export function createClient() {
return createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);
}
53 changes: 53 additions & 0 deletions packages/supabase/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { createServerClient } from '@supabase/ssr';
import { type NextRequest, NextResponse } from 'next/server';

export const updateSession = async (request: NextRequest) => {
try {
let response = NextResponse.next({
request: {
headers: request.headers,
},
});

const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
getAll() {
return request.cookies.getAll();
},
setAll(cookiesToSet) {
cookiesToSet.forEach(({ name, value }) =>
request.cookies.set(name, value)
);
response = NextResponse.next({
request,
});
cookiesToSet.forEach(({ name, value, options }) =>
response.cookies.set(name, value, options)
);
},
},
}
);

const user = await supabase.auth.getUser();

if (request.nextUrl.pathname.startsWith('/protected') && user.error) {
return NextResponse.redirect(new URL('/sign-in', request.url));
}

if (request.nextUrl.pathname === '/' && !user.error) {
return NextResponse.redirect(new URL('/protected', request.url));
}

return response;
} catch (e) {

Check failure on line 46 in packages/supabase/src/middleware.ts

View workflow job for this annotation

GitHub Actions / lint

'e' is defined but never used
return NextResponse.next({
request: {
headers: request.headers,
},
});
}
};
29 changes: 29 additions & 0 deletions packages/supabase/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createServerClient } from '@supabase/ssr';
import { cookies } from 'next/headers';

export const createClient = async () => {
const cookieStore = await cookies();

return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) => {
cookieStore.set(name, value, options);
});
} catch (error) {

Check failure on line 20 in packages/supabase/src/server.ts

View workflow job for this annotation

GitHub Actions / lint

'error' is defined but never used
// The `set` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
},
}
);
};
11 changes: 11 additions & 0 deletions packages/supabase/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@ultra-reporter/typescript-config/nextjs.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"],
"exclude": ["node_modules"]
}
4 changes: 2 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"cmdk": "1.0.4",
"embla-carousel-react": "^8.5.1",
"lucide-react": "^0.469.0",
"next": "15.1.2",
"next": "15.1.3",
"next-themes": "^0.4.4",
"react-code-blocks": "^0.1.6",
"react-hook-form": "^7.54.2",
Expand All @@ -63,7 +63,7 @@
"@ultra-reporter/typescript-config": "workspace:*",
"@ultra-reporter/utils": "workspace:*",
"autoprefixer": "^10.4.20",
"daisyui": "^4.12.22",
"daisyui": "^4.12.23",
"postcss": "^8.4.49",
"postcss-load-config": "^6.0.1",
"tailwindcss": "^3.4.17"
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"luxon": "^3.5.0",
"next": "15.1.2",
"next": "15.1.3",
"react": "^19.0.0",
"tailwind-merge": "^2.5.5",
"tailwind-merge": "^2.6.0",
"xml2js": "^0.6.2"
}
}
Loading

0 comments on commit b6d08e5

Please sign in to comment.