From 55414d069310ce8af4d03fda26a04ee5779b6848 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Thu, 12 Feb 2026 21:14:23 +0800 Subject: [PATCH] feat: update .gitignore, auth configuration, and add GitHub API client --- .env.example | 4 +++- .gitignore | 4 +++- convex/auth.config.ts | 2 +- convex/github/starrred.ts | 4 +++- package.json | 1 + pnpm-lock.yaml | 8 ++++++++ src/github/get.ts | 18 ++++++++++++++++++ tsconfig.json | 3 +++ 8 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 src/github/get.ts diff --git a/.env.example b/.env.example index 8115924..b17e4a8 100644 --- a/.env.example +++ b/.env.example @@ -2,4 +2,6 @@ CONVEX_SELF_HOSTED_ADMIN_KEY= CONVEX_SELF_HOSTED_URL=http://localhost:3210 # CONVEX_SELF_HOSTED_URL=https://convex.kevisual.cn -CONVEX_SITE_URL=https://api-convex.kevisual.cn \ No newline at end of file +CONVEX_SITE_URL=https://api-convex.kevisual.cn + +KEVISUAL_CONVEX_TOKEN= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0a6c339..e030268 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ release/* !.env.example pack-dist -.pnpm-store \ No newline at end of file +.pnpm-store + +storage \ No newline at end of file diff --git a/convex/auth.config.ts b/convex/auth.config.ts index a9ffde1..5c1f549 100644 --- a/convex/auth.config.ts +++ b/convex/auth.config.ts @@ -6,7 +6,7 @@ export default { type: "customJwt", applicationID: "convex-app", issuer: "https://convex.kevisual.cn", - jwks: "https://api-convex.kevisual.cn/root/convex/jwks.json", + jwks: "https://kevisual.cn/api/convex/jwks.json", algorithm: "RS256", }, ], diff --git a/convex/github/starrred.ts b/convex/github/starrred.ts index fc73955..7c4b5cb 100644 --- a/convex/github/starrred.ts +++ b/convex/github/starrred.ts @@ -3,6 +3,8 @@ import { query, mutation, action } from "../_generated/server.js"; export const get = query({ args: {}, handler: async (ctx) => { - return await ctx.db.query("github_starred").collect(); + const user = await ctx.auth.getUserIdentity(); + console.log('user', user) + return await ctx.db.query("github_starred").take(1); }, }); diff --git a/package.json b/package.json index 5dc2f8b..15a0589 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@types/node": "^25.2.0" }, "dependencies": { + "@kevisual/auth": "^2.0.3", "convex": "1.31.7", "jose": "^6.1.3" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dc7a964..0157fbe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@kevisual/auth': + specifier: ^2.0.3 + version: 2.0.3 convex: specifier: 1.31.7 version: 1.31.7 @@ -183,6 +186,9 @@ packages: cpu: [x64] os: [win32] + '@kevisual/auth@2.0.3': + resolution: {integrity: sha512-4xpijaIhlCTr/DlJaV/gmkCQeg45EO1yxWpRvUX+1jCdVbuxSR0wZrF0SD9oybnjmKWMKDNPLsXyduFjMGcItA==} + '@kevisual/types@0.0.12': resolution: {integrity: sha512-zJXH2dosir3jVrQ6QG4i0+iLQeT9gJ3H+cKXs8ReWboxBSYzUZO78XssVeVrFPsJ33iaAqo4q3DWbSS1dWGn7Q==} @@ -307,6 +313,8 @@ snapshots: '@esbuild/win32-x64@0.27.0': optional: true + '@kevisual/auth@2.0.3': {} + '@kevisual/types@0.0.12': {} '@types/bun@1.3.8': diff --git a/src/github/get.ts b/src/github/get.ts new file mode 100644 index 0000000..f2858ab --- /dev/null +++ b/src/github/get.ts @@ -0,0 +1,18 @@ +import { api } from '@/convex/_generated/api.js'; +import { ConvexClient, AuthTokenFetcher } from "convex/browser"; +const url = process.env["CONVEX_URL"] +const client = new ConvexClient(url!); + +const token = process.env["KEVISUAL_CONVEX_TOKEN"] +const authTokenFetcher: AuthTokenFetcher = async ({ forceRefreshToken }: { forceRefreshToken: boolean }) => { + console.log("AuthTokenFetcher called, forceRefreshToken:", forceRefreshToken); + return token; +} +client.setAuth(authTokenFetcher, (isAuthenticated) => { + console.log("Auth isAuthenticated:", isAuthenticated); +}); + +await Bun.sleep(1000); +const list = await client.query(api.github.starrred.get, {}) + +console.log('list', list) diff --git a/tsconfig.json b/tsconfig.json index 2dc6e8b..6309108 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,9 @@ "paths": { "@/*": [ "src/*" + ], + "@/convex/*": [ + "convex/*" ] }, },