30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { ConvexClient, AuthTokenFetcher } from "convex/browser";
|
|
import { api } from "./convex/_generated/api.js";
|
|
|
|
const url = process.env["CONVEX_URL"]
|
|
const client = new ConvexClient(url!);
|
|
console.log("Client created", url);
|
|
const authTokenFetcher: AuthTokenFetcher = async ({ forceRefreshToken }: { forceRefreshToken: boolean }) => {
|
|
console.log("AuthTokenFetcher called, forceRefreshToken:", forceRefreshToken);
|
|
return null;
|
|
}
|
|
const _auth = await client.setAuth(authTokenFetcher, () => { })
|
|
const auth = client.getAuth();
|
|
console.log("Client auth", auth);
|
|
const unsubscribe = client.onUpdate(api.abcv.get, {}, async (tasks) => {
|
|
console.log(tasks);
|
|
});
|
|
|
|
// const list = await client.query(api.abcv.get, {});
|
|
// console.log("Initial list:", list);
|
|
// for (let i = 0; i < list.length; i++) {
|
|
// const a = list[i];
|
|
// console.log(`Item ${i}:`, a.title);
|
|
// }
|
|
// const list = await client.action(api.abcv.chat, { message: "Hello, 1+1=?" });
|
|
// console.log("Chat response:", list);
|
|
const xiongList = await client.query(api.xiong.get, {});
|
|
console.log("Xiong list:", xiongList);
|
|
await Bun.sleep(1000);
|
|
unsubscribe();
|
|
await client.close(); |