Skip to content
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
10 changes: 10 additions & 0 deletions apps/web/app/(auth)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Layout = ({ children }: { children: React.ReactNode }) => {
return (
<div className="min-h-screen min-w-screen flex flex-col items-center justify-center">
{children}
</div>
);
};

export default Layout;

12 changes: 12 additions & 0 deletions apps/web/app/(auth)/sign-in/[[...sign-in]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { SignIn } from '@clerk/nextjs'
import React from 'react'

const Page = () => {
return (
<div>
<SignIn/>
</div>
)
}

export default Page
12 changes: 12 additions & 0 deletions apps/web/app/(auth)/sign-up/[[...sgn-up]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { SignUp } from '@clerk/nextjs'
import React from 'react'

const Page = () => {
return (
<div>
<SignUp/>
</div>
)
}

export default Page
5 changes: 4 additions & 1 deletion apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Geist, Geist_Mono } from "next/font/google"

import "@workspace/ui/globals.css"
import { Providers } from "@/components/providers"
import { ClerkProvider } from "@clerk/nextjs"

const fontSans = Geist({
subsets: ["latin"],
Expand All @@ -23,7 +24,9 @@ export default function RootLayout({
<body
className={`${fontSans.variable} ${fontMono.variable} font-sans antialiased `}
>
<Providers>{children}</Providers>
<ClerkProvider>
<Providers>{children}</Providers>
</ClerkProvider>
</body>
</html>
)
Expand Down
18 changes: 17 additions & 1 deletion apps/web/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
"use client"

import { useQuery } from 'convex/react';
import { Authenticated, Unauthenticated, useMutation, useQuery } from 'convex/react';
import { api } from "@workspace/backend/_generated/api";
import { SignInButton, UserButton } from '@clerk/nextjs';
import { Button } from "../../../packages/ui/src/components/button"

export default function Page() {

const users = useQuery(api.users.getMany);
const addUser = useMutation(api.users.add);

return (
<>
<Authenticated>
<div className="flex items-center justify-center min-h-svh">
<div className="flex flex-col items-center justify-center gap-4">
<UserButton/>
<Button onClick={()=>addUser()}>ADD</Button>
{JSON.stringify(users)}
{JSON.stringify(users)}
</div>
</div>
</Authenticated>
<Unauthenticated>
<p>Must be signed in!</p>
<SignInButton>SignIn!</SignInButton>
</Unauthenticated>

</>
)
}
11 changes: 11 additions & 0 deletions apps/web/app/test/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

const Page = () => {
return (
<div>
Test Page
</div>
)
}

export default Page
12 changes: 9 additions & 3 deletions apps/web/components/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
"use client"

import * as React from "react"
import { useAuth } from '@clerk/nextjs'
import { ThemeProvider as NextThemesProvider } from "next-themes"
import { ConvexProvider , ConvexReactClient } from "convex/react"
import { ConvexReactClient } from "convex/react"
import { ConvexProviderWithClerk } from 'convex/react-clerk'

if (!process.env.NEXT_PUBLIC_CONVEX_URL) {
throw new Error('Missing NEXT_PUBLIC_CONVEX_URL in your .env file')
}

export function Providers({ children }: { children: React.ReactNode }) {
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL || "");
Expand All @@ -14,9 +20,9 @@ export function Providers({ children }: { children: React.ReactNode }) {
disableTransitionOnChange
enableColorScheme
>
<ConvexProvider client={convex}>
<ConvexProviderWithClerk client={convex} useAuth={useAuth}>
{children}
</ConvexProvider>
</ConvexProviderWithClerk>
</NextThemesProvider>
)
}
22 changes: 22 additions & 0 deletions apps/web/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { clerkMiddleware , createRouteMatcher } from '@clerk/nextjs/server'

const isPublicRoute = createRouteMatcher([
"/sign-in(.*)",
"/sign-up(.*)",
"/test"
])

export default clerkMiddleware(async (auth,req) => {
if(!isPublicRoute(req)) {
await auth.protect();
}
})

export const config = {
matcher: [
// Skip Next.js internals and all static files, unless found in search params
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
// Always run for API routes
'/(api|trpc)(.*)',
],
}
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@workspace/backend" : "workspace:*",
"@clerk/nextjs": "^6.31.6",
"@workspace/backend": "workspace:*",
"@workspace/math": "workspace:*",
"@workspace/ui": "workspace:*",
"convex": "1.25.4",
Expand Down
1 change: 1 addition & 0 deletions apps/widget/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function Page() {
<div className="flex flex-col items-center justify-center gap-4">
<Button onClick={()=>addUser()}>ADD</Button>
{JSON.stringify(users)}
<p>Widget Page</p>
</div>
</div>
)
Expand Down
8 changes: 8 additions & 0 deletions packages/backend/convex/auth.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
providers : [
{
domain : process.env.CLERK_JWT_ISSUER_DOMAIN,
applicationID : 'convex',
}
]
}
5 changes: 5 additions & 0 deletions packages/backend/convex/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ export const getMany = query({
export const add = mutation({
args : {},
handler : async(ctx) => {
const identity = await ctx.auth.getUserIdentity();
console.log(identity);
if( identity === null ) {
throw new Error('Not Authenticated!')
}
const userID = await ctx.db.insert("users" , {
name : "antonio",
});
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"./react-internal": "./react-internal.js"
},
"devDependencies": {
"@eslint/js": "^9.34.0",
"@eslint/js": "^9.32.0",
"@next/eslint-plugin-next": "^15.4.5",
"@typescript-eslint/eslint-plugin": "^8.39.0",
"@typescript-eslint/parser": "^8.39.0",
"eslint": "^9.32.0",
"eslint": "^9.32.1",
"eslint-config-prettier": "^9.1.2",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-react": "^7.37.5",
Expand Down
Loading