Skip to content

Commit

Permalink
Merge pull request #54 from wtfdivyansh/feature/backend
Browse files Browse the repository at this point in the history
backend fix
  • Loading branch information
SkidGod4444 authored Nov 16, 2024
2 parents 65f96b6 + 5c22dd6 commit 98bc7c7
Show file tree
Hide file tree
Showing 13 changed files with 786 additions and 566 deletions.
2 changes: 1 addition & 1 deletion apps/app/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { betterFetch } from "@better-fetch/fetch";
import type { Session } from "better-auth/types";
import type { Session } from "@repo/auth";
import { NextResponse, type NextRequest } from "next/server";
const baseDomain =
process.env.NODE_ENV === "production"
Expand Down
10 changes: 6 additions & 4 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache"
},
"dependencies": {
"@better-fetch/fetch": "^1.1.12",
"@hookform/resolvers": "^3.9.1",
"@radix-ui/react-alert-dialog": "^1.1.2",
"@radix-ui/react-avatar": "^1.1.1",
Expand All @@ -29,12 +30,16 @@
"@radix-ui/react-toggle": "^1.1.0",
"@radix-ui/react-toggle-group": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.3",
"@repo/auth": "workspace:*",
"@repo/db": "workspace:*",
"@repo/types": "workspace:*",
"@tabler/icons-react": "^3.21.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cmdk": "1.0.0",
"contentlayer2": "^0.5.3",
"framer-motion": "^11.11.11",
"geist": "^1.3.1",
"input-otp": "^1.4.1",
"lucide-react": "^0.454.0",
"next": "15.0.2",
Expand All @@ -47,10 +52,7 @@
"sonner": "^1.7.0",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.23.8",
"@repo/auth": "workspace:*",
"@repo/db": "workspace:*",
"@repo/types": "workspace:*"
"zod": "^3.23.8"
},
"devDependencies": {
"@types/node": "^20",
Expand Down
2 changes: 1 addition & 1 deletion apps/triggers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "triggers",
"version": "1.0.0",
"scripts": {
"dev": "pnpm dlx trigger.dev@latest dev",
"trigger": "pnpm dlx trigger.dev@latest dev",
"deploy": "pnpm dlx trigger.dev@latest deploy"
},
"keywords": [],
Expand Down
24 changes: 21 additions & 3 deletions apps/www/app/(auth)/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
"use client";
import AccountSwitcher from "@/components/custom/account-switcher";
import { authClient } from "@/lib/auth-client";
import { getMultipleSessions, getSession } from "@/lib/server";
import { Session } from "@repo/auth";
import { usePathname } from "next/navigation";
import { use, useEffect, useState } from "react";

export default async function page() {
const session = await getSession();
const multipleSessions = await getMultipleSessions();
export default function page() {
const [session, setSession] = useState<Session | null>(null);
const [multipleSessions, setMultipleSessions] = useState<Session[] | null>(
null,
);
useEffect(() => {
async function getData() {
const session = await authClient.getSession();
const multipleSessions =
await authClient.multiSession.listDeviceSessions();
setSession(session.data);
setMultipleSessions(multipleSessions.data);
console.log("i am here");
}
getData();
}, []);
return (
<div>
<AccountSwitcher session={multipleSessions} activeSession={session} />
Expand Down
12 changes: 9 additions & 3 deletions apps/www/components/custom/account-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { authClient } from "@/lib/auth-client";
import { Session } from "@repo/auth";
import { useRouter } from "next/navigation";
interface Props {
session: Session[];
activeSession: Session;
session: Session[] | null;
activeSession: Session | null;
}
export default function AccountSwitcher({ session, activeSession }: Props) {
const router = useRouter();
Expand All @@ -15,17 +15,23 @@ export default function AccountSwitcher({ session, activeSession }: Props) {
});

console.log(active);
router.refresh();
window.location.reload();
};
const handleSignOut = async () => {
await authClient.signOut({
fetchOptions: {
onSuccess: () => {
router.push("/auth");
},
onError: (ctx) => {
console.log("error", ctx.error);
},
},
});
};
if (!activeSession || !session) {
return <div>loading sessions</div>;
}
return (
<div className="flex items-center justify-center gap-2 p-4">
<select
Expand Down
2 changes: 1 addition & 1 deletion apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
"typescript": "^5",
"vitest": "^2.1.4"
}
}
}
21 changes: 4 additions & 17 deletions apps/www/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -23,18 +19,9 @@
}
],
"paths": {
"@/*": [
"./*"
]
"@/*": ["./*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"format:check": "turbo run format:check"
},
"devDependencies": {
"@repo/typescript-config": "workspace:*",
"@types/node": "^22.9.0",
"@types/react": "^18.3.12",
"@types/supertest": "^6.0.2",
Expand All @@ -50,7 +51,7 @@
"posthog-js": "^1.184.1",
"supertest": "^7.0.0",
"tailwindcss": "^3.4.1",
"typescript": "^5",
"typescript": "^5.6.3",
"vite-tsconfig-paths": "^5.1.0",
"vitest": "^2.1.4"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"exports": {
".": "./src/auth.ts"
},

"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@repo/typescript-config": "workspace:*",
"@repo/db": "workspace:*",
"better-auth": "0.8.1-beta.1",
"better-auth": "0.8.5-beta.2",
"better-call": "0.2.14-beta.3",
"oslo": "^1.2.1"
}
}
}
12 changes: 5 additions & 7 deletions packages/auth/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { multiSession } from "better-auth/plugins";

const BaseDomain = process.env.NODE_ENV === "production" ? process.env.API_DOMAIN as string : "http://localhost:3001";


export const config = {
export const auth = betterAuth({
trustedOrigins: [
"https://www.plura.pro",
"https://plura.pro",
Expand All @@ -28,24 +27,23 @@ export const config = {
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
},
discord:{
discord: {
clientId: process.env.DISCORD_CLIENT_ID!,
clientSecret: process.env.DISCORD_CLIENT_SECRET!,
},
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}
},
},
...(process.env.NODE_ENV === "production" && {
advanced: {
crossSubDomainCookies: {
enabled: true,
domain: "plura.pro",
},
},
}),
} satisfies BetterAuthOptions;

export const auth = betterAuth(config);
});

export type Session = typeof auth.$Infer.Session;
5 changes: 5 additions & 0 deletions packages/auth/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "@repo/typescript-config/base.json",
"include": ["src", "*.ts"],
"exclude": ["node_modules"]
}
4 changes: 2 additions & 2 deletions packages/typescript-config/base.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"declaration": false,
"declarationMap": false,
"esModuleInterop": true,
"incremental": true,
"isolatedModules": true,
Expand Down
Loading

0 comments on commit 98bc7c7

Please sign in to comment.