Skip to content

Commit 9703b70

Browse files
priley86AdamWozniewski
authored andcommitted
feat: code review updates
1 parent 88a0efc commit 9703b70

File tree

11 files changed

+391
-261
lines changed

11 files changed

+391
-261
lines changed
Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
{
2-
"extends": "next/core-web-vitals"
3-
}
2+
"root": true,
3+
"extends": [
4+
"next/core-web-vitals",
5+
"plugin:@typescript-eslint/recommended"
6+
],
7+
"parser": "@typescript-eslint/parser",
8+
"plugins": [
9+
"@typescript-eslint",
10+
"import"
11+
],
12+
"rules": {
13+
"@typescript-eslint/no-var-requires": "off",
14+
"import/no-commonjs": "off",
15+
"@typescript-eslint/no-explicit-any": "off",
16+
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
17+
"@typescript-eslint/no-require-imports": "off",
18+
"@typescript-eslint/no-unused-vars": "warn"
19+
},
20+
"overrides": [
21+
{
22+
"files": ["*.config.{js,cjs,mjs}", "scripts/**", "next.config.*", "postcss.config.js", "tailwind.config.*"],
23+
"rules": {
24+
"@typescript-eslint/no-var-requires": "off",
25+
"import/no-commonjs": "off"
26+
}
27+
},
28+
{
29+
"files": ["**/__tests__/**", "**/*.test.{ts,tsx}"],
30+
"env": { "jest": true }
31+
}
32+
]
33+
}

asynchronous-authorization/langchain-next-js/bun.lock

Lines changed: 267 additions & 193 deletions
Large diffs are not rendered by default.

asynchronous-authorization/langchain-next-js/package.json

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,71 +22,71 @@
2222
"fga:init": "tsx src/lib/fga/fga-init.ts"
2323
},
2424
"engines": {
25-
"node": ">=18"
25+
"node": ">=20 <23"
2626
},
2727
"dependencies": {
28-
"@auth0/ai": "4.0.0",
2928
"@auth0/ai-langchain": "^3.5.0",
30-
"@auth0/nextjs-auth0": "4.4.2",
31-
"@langchain/community": "0.3.53",
32-
"@langchain/core": "^0.3.77",
33-
"@langchain/langgraph": "^0.4.4",
34-
"@langchain/langgraph-sdk": "^0.1.8",
35-
"@langchain/openai": "^0.6.13",
36-
"@radix-ui/react-avatar": "^1.1.7",
37-
"@radix-ui/react-checkbox": "^1.2.3",
38-
"@radix-ui/react-dialog": "^1.1.11",
39-
"@radix-ui/react-dropdown-menu": "^2.1.12",
40-
"@radix-ui/react-popover": "^1.1.11",
41-
"@radix-ui/react-slot": "^1.2.0",
42-
"@types/pg": "^8.15.4",
29+
"@auth0/nextjs-auth0": "^4.10.0",
30+
"@langchain/community": "^0.3.55",
31+
"@langchain/core": "^0.3.75",
32+
"@langchain/langgraph": "^0.4.9",
33+
"@langchain/openai": "^0.6.11",
34+
"@radix-ui/react-avatar": "^1.1.10",
35+
"@radix-ui/react-checkbox": "^1.3.3",
36+
"@radix-ui/react-dialog": "^1.1.15",
37+
"@radix-ui/react-dropdown-menu": "^2.1.16",
38+
"@radix-ui/react-popover": "^1.1.15",
39+
"@radix-ui/react-slot": "^1.2.3",
40+
"@types/pg": "^8.15.5",
4341
"class-variance-authority": "^0.7.1",
4442
"clsx": "^2.1.1",
4543
"date-fns": "^4.1.0",
46-
"dotenv": "^17.0.1",
47-
"drizzle-orm": "^0.43.1",
48-
"drizzle-zod": "^0.7.1",
49-
"googleapis": "^148.0.0",
50-
"jose": "^6.1.0",
51-
"langchain": "^0.3.12",
44+
"drizzle-orm": "^0.44.5",
45+
"drizzle-zod": "0.7.1",
46+
"googleapis": "^159.0.0",
47+
"langchain": "^0.3.33",
5248
"langgraph-nextjs-api-passthrough": "^0.1.4",
53-
"lucide-react": "^0.475.0",
54-
"marked": "^15.0.7",
49+
"lucide-react": "^0.543.0",
50+
"marked": "^16.2.1",
5551
"nanoid": "^5.1.5",
56-
"next": "15.2.4",
57-
"next-themes": "^0.4.4",
58-
"nuqs": "^2.4.3",
52+
"next": "^15.5.4",
53+
"next-themes": "^0.4.6",
54+
"nuqs": "^2.6.0",
5955
"pdf-parse": "^1.1.1",
6056
"pg": "^8.16.3",
61-
"postgres": "^3.4.5",
62-
"react": "19.0.0",
57+
"postgres": "^3.4.7",
58+
"react": "^19.1.1",
6359
"react-device-detect": "^2.2.3",
64-
"react-dom": "19.0.0",
65-
"react-markdown": "^10.0.0",
66-
"react-toastify": "11.0.3",
67-
"sonner": "^1.7.2",
68-
"tailwind-merge": "^2.6.0",
60+
"react-dom": "^19.1.1",
61+
"react-markdown": "^10.1.0",
62+
"react-toastify": "^11.0.5",
63+
"sonner": "^2.0.7",
64+
"tailwind-merge": "^3.3.1",
6965
"tailwindcss-animate": "^1.0.7",
70-
"use-stick-to-bottom": "^1.0.44",
66+
"use-stick-to-bottom": "^1.1.1",
7167
"vaul": "^1.1.2",
72-
"zod": "^3.24.2",
68+
"zod": "3.25.76 || ^4",
7369
"zod-to-json-schema": "^3.23.2"
7470
},
7571
"devDependencies": {
76-
"@next/bundle-analyzer": "^15.1.7",
77-
"@types/node": "^22.13.4",
72+
"@next/bundle-analyzer": "^15.5.2",
73+
"@types/node": "^24.3.1",
7874
"@types/pdf-parse": "^1.1.5",
79-
"@types/react": "19.0.9",
80-
"@types/react-dom": "19.0.3",
81-
"autoprefixer": "^10.4.20",
82-
"drizzle-kit": "^0.31.1",
83-
"eslint": "^9.20.1",
84-
"eslint-config-next": "^15.1.7",
75+
"@types/react": "^19.1.12",
76+
"@types/react-dom": "^19.1.9",
77+
"@typescript-eslint/eslint-plugin": "^8.45.0",
78+
"@typescript-eslint/parser": "^8.45.0",
79+
"autoprefixer": "^10.4.21",
80+
"dotenv": "^16.4.5",
81+
"drizzle-kit": "^0.31.4",
82+
"eslint": "^9.36.0",
83+
"eslint-config-next": "^15.5.2",
84+
"eslint-plugin-import": "^2.32.0",
8585
"npm-run-all": "^4.1.5",
86-
"postcss": "8.5.2",
87-
"prettier": "^3.4.2",
88-
"tailwindcss": "3.4.17",
89-
"tsx": "^4.19.4",
90-
"typescript": "5.7.3"
86+
"postcss": "^8.5.6",
87+
"prettier": "^3.6.2",
88+
"tailwindcss": "^3.4.17",
89+
"tsx": "^4.20.5",
90+
"typescript": "^5.9.2"
9191
}
92-
}
92+
}
File renamed without changes.

asynchronous-authorization/vercel-ai-next-js/.env.example

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ AUTH0_CLIENT_SECRET="{yourClientSecret}"
1111
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/ai_documents_db"
1212

1313
# Auth0 FGA
14-
FGA_STORE_ID=<your-fga-store-id>
15-
FGA_CLIENT_ID=<your-fga-store-client-id>
16-
FGA_CLIENT_SECRET=<your-fga-store-client-secret>
17-
FGA_API_URL=https://api.xxx.fga.dev
18-
FGA_API_AUDIENCE=https://api.xxx.fga.dev/
19-
FGA_API_TOKEN_ISSUER=auth.fga.dev
14+
# FGA_STORE_ID=<your-fga-store-id>
15+
# FGA_CLIENT_ID=<your-fga-store-client-id>
16+
# FGA_CLIENT_SECRET=<your-fga-store-client-secret>
17+
# FGA_API_URL=https://api.xxx.fga.dev
18+
# FGA_API_AUDIENCE=https://api.xxx.fga.dev/
19+
# FGA_API_TOKEN_ISSUER=auth.fga.dev
2020

2121
# API (OPTIONAL)
2222
# SHOP_API_URL=<your-shop-api-url>

asynchronous-authorization/vercel-ai-next-js/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

33
# dependencies
4-
./package-lock.json
54
/node_modules
65
/.pnp
76
.pnp.js

asynchronous-authorization/vercel-ai-next-js/src/app/globals.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
@import "tailwindcss";
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
24

35
@layer base {
46
:root {
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
import type { NextRequest } from "next/server"
2-
3-
import { auth0 } from "./lib/auth0"
1+
import { NextRequest, NextResponse } from 'next/server';
2+
import { auth0 } from './lib/auth0';
43

54
export async function middleware(request: NextRequest) {
6-
return await auth0.middleware(request);
5+
const authRes = await auth0.middleware(request);
6+
7+
// Authentication routes — let the Auth0 middleware handle it.
8+
if (request.nextUrl.pathname.startsWith('/auth')) {
9+
return authRes;
10+
}
11+
12+
const { origin } = new URL(request.url);
13+
const session = await auth0.getSession(request);
14+
15+
// User does not have a session — redirect to login.
16+
if (!session) {
17+
return NextResponse.redirect(`${origin}/auth/login`);
18+
}
19+
return authRes;
720
}
821

922
export const config = {
@@ -14,6 +27,6 @@ export const config = {
1427
* - _next/image (image optimization files)
1528
* - favicon.ico, sitemap.xml, robots.txt (metadata files)
1629
*/
17-
"/((?!_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
30+
'/((?!_next/static|_next/image|images|favicon.[ico|png]|sitemap.xml|robots.txt|$).*)',
1831
],
1932
}

asynchronous-authorization/vercel-ai-node-js/README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,22 @@ OPENAI_API_KEY="openai-api-key"
4646
bun install
4747
```
4848

49-
2. Running the example
49+
2. Update your user id in the sample [src/index.ts](./src/index.ts) provided.
50+
```typescript
51+
const { text } = await generateText({
52+
model: openai("gpt-4o-mini"),
53+
system: "You are an assistant. Invoke the tool if needed, then respond with a past-tense confirmation.",
54+
prompt: userPrompt,
55+
// pass an Auth0 user id. For example, 'auth0|100000000000000000000' or 'google-oauth2|100000000000000000000'
56+
tools: { buy: buy({ userId: "<authenticated-user-id>" }) },
57+
stopWhen: stepCountIs(3), // tool call + result + final assistant message
58+
});
59+
```
60+
61+
3. Running the example
5062

5163
```sh
52-
npm start
64+
bun start
5365
```
5466

5567
## License

authorization-for-rag/langchain-next-js/src/lib/actions/documents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { auth0 } from '@/lib/auth0';
1616
export const createDocument = async (input: NewDocumentParams, text: string) => {
1717
const session = await auth0.getSession();
1818
const user = session?.user;
19-
if (!user || !user.email || !user.sub) throw new Error('User not authenticated');
19+
if (!user || !user.email) throw new Error('User not authenticated');
2020

2121
const { content, fileName, fileType, sharedWith } = insertDocumentSchema.parse(input);
2222

0 commit comments

Comments
 (0)