Web Dev Cody
Web Dev Cody
CCConvex Community
Created by Web Dev Cody on 10/5/2024 in #support-community
Convex in stackblitz
No description
5 replies
CCConvex Community
Created by Web Dev Cody on 10/2/2024 in #support-community
Understanding usePaginatedQuery
I'm trying to wrap my head around how to use a page based usePaginatedQuery, so basically if a user hits /posts?page=1 or /posts?page=2, I want to fetch 5 items and change the offset.
the usePaginatedQuery seems to be more like a lazy scroll type of thing. Maybe I'm missing something?
23 replies
CCConvex Community
Created by Web Dev Cody on 9/30/2024 in #support-community
youtube api in action
I'm trying to upload a file to youtube from a convex action, but I get this error:
Uncaught TypeError: part.body.pipe is not a function
at multipartUpload (../node_modules/googleapis-common/build/src/apirequest.js:180:12)
at createAPIRequestAsync (../node_modules/googleapis-common/build/src/apirequest.js:219:12)
at createAPIRequest (../node_modules/googleapis-common/build/src/apirequest.js:52:4)
at insert [as insert] (../node_modules/googleapis/build/src/apis/youtube/v3.js:2595:12)
at handler (../convex/youtube.ts:104:6)
Uncaught TypeError: part.body.pipe is not a function
at multipartUpload (../node_modules/googleapis-common/build/src/apirequest.js:180:12)
at createAPIRequestAsync (../node_modules/googleapis-common/build/src/apirequest.js:219:12)
at createAPIRequest (../node_modules/googleapis-common/build/src/apirequest.js:52:4)
at insert [as insert] (../node_modules/googleapis/build/src/apis/youtube/v3.js:2595:12)
at handler (../convex/youtube.ts:104:6)
const youtube = google.youtube({ version: "v3", auth: oauth2Client });
const fileStream = file.stream();
const fileSize = file.size;

await youtube.videos.insert(
{
part: ["snippet", "status"],
requestBody: {
snippet: {
title: video.title,
description: "this video was created using thevideocrafter.com",
},
status: {
privacyStatus: "private",
},
},
media: {
body: fileStream,
},
},
{
onUploadProgress: (evt) => {
const progress = (evt.bytesRead / fileSize) * 100;
console.log(`${progress.toFixed(2)}% complete`);
},
}
);
const youtube = google.youtube({ version: "v3", auth: oauth2Client });
const fileStream = file.stream();
const fileSize = file.size;

await youtube.videos.insert(
{
part: ["snippet", "status"],
requestBody: {
snippet: {
title: video.title,
description: "this video was created using thevideocrafter.com",
},
status: {
privacyStatus: "private",
},
},
media: {
body: fileStream,
},
},
{
onUploadProgress: (evt) => {
const progress = (evt.bytesRead / fileSize) * 100;
console.log(`${progress.toFixed(2)}% complete`);
},
}
);
5 replies
CCConvex Community
Created by Web Dev Cody on 9/24/2024 in #support-community
Custom Convex Domain
When using a custom convex domain, is the project id obfenscated away from the end user? like is that project id embedded in any type of websocket event that someone could get to then use to hit my convex storage if they wanted?
6 replies
CCConvex Community
Created by Web Dev Cody on 9/24/2024 in #support-community
Get all documents where storageId not null
How would I achieve this query? I have a table with an index on an optional storageId field, but when doing the withIndex I can't seem to pass gte('file', undefined)
6 replies
CCConvex Community
Created by Web Dev Cody on 9/21/2024 in #support-community
Delete all files
Is there an easy way to clear all files in convex storage? I'm doing 20 at a time and I have 1k total.
17 replies
CCConvex Community
Created by Web Dev Cody on 9/16/2024 in #support-community
Has anyone else seen this issue? openai api blocking convex?
No description
5 replies
CCConvex Community
Created by Web Dev Cody on 9/3/2024 in #support-community
Simulate Convex Auth Invalid
I've noticed that sometimes when my users leave my site open for a while, their convex auth session becomes invalid. This usually means when a user clicks on a button, the mutation throws an auth error. Is there some standard way to handle this type of issue? It would be nice if there was a way to wrap useMutation or useQuery in custom logic to redirect the user if an auth error gets returned from my api.
5 replies
CCConvex Community
Created by Web Dev Cody on 9/3/2024 in #support-community
Convex Auth Question
No description
9 replies
CCConvex Community
Created by Web Dev Cody on 8/29/2024 in #support-community
Help with Openai Whipser
so in convex, I'm trying to generate some text to speech using this sdk
async function generateAudio(text: string) {
const mp3 = await openai.audio.speech.create({
model: "tts-1",
voice: "onyx",
input: text,
});
const buffer = Buffer.from(await mp3.arrayBuffer());
return buffer;
}
async function generateAudio(text: string) {
const mp3 = await openai.audio.speech.create({
model: "tts-1",
voice: "onyx",
input: text,
});
const buffer = Buffer.from(await mp3.arrayBuffer());
return buffer;
}
and then I'm trying to pass that to this type of function
export async function getTranscripts(audio: Buffer) {
try {
const transcription = await openai.audio.transcriptions.create({
file: audio,
model: "whisper-1",
timestamp_granularities: ["word"],
response_format: "verbose_json",
});
return transcription;
} finally {
// No cleanup needed as we didn't create any files
}
}
export async function getTranscripts(audio: Buffer) {
try {
const transcription = await openai.audio.transcriptions.create({
file: audio,
model: "whisper-1",
timestamp_granularities: ["word"],
response_format: "verbose_json",
});
return transcription;
} finally {
// No cleanup needed as we didn't create any files
}
}
8 replies
CCConvex Community
Created by Web Dev Cody on 8/24/2024 in #support-community
Error I can't get
No description
10 replies
CCConvex Community
Created by Web Dev Cody on 8/19/2024 in #support-community
Question about Error
I have a page in react which does a useQuery(api.stories.getStory), and I also have a button on that page which deletes that story resource. I'm seeing an issue where after I delete the resource, I have logic to redirect back to another page, but the useQuery seems to fire before the redirect finished and causes the app to throw an error.
Does anyone have a pattern I can use to prevent this type of issue? The only approach I know of it to never have queries throw errors, and instead just have them return null or undefined or something
11 replies
CCConvex Community
Created by Web Dev Cody on 8/18/2024 in #support-community
Using convex docs in Cursor
I started using cursor ai, and I was curious if there was a good way to export all the convex docs into .md files that I could include as context in cursor for when I have it do work. Has anyone else done something like this? I guess I could just manually copy .md files from the convex github repo into my project and use those directly.
8 replies
CCConvex Community
Created by Web Dev Cody on 8/18/2024 in #support-community
Pass auth context to actions
I am trying to call a mutation which schedules an internal action. This action uses other internal queries which check authotization, so I'm finding I often need to split one useful quey into a query and a helper function. Is there a nicer was to reuse code with my approach?
7 replies
CCConvex Community
Created by Web Dev Cody on 8/16/2024 in #support-community
HTTP Headers Sent
No description
14 replies
CCConvex Community
Created by Web Dev Cody on 8/15/2024 in #support-community
Calling convex mutations / queries from other repo
I'm curious what the best practice is for if I have my convex project in 1 repo, but I want to invoke just a single query or mutation from another repo using the node sdk? Is there a way to achieve this?
7 replies
CCConvex Community
Created by Web Dev Cody on 8/14/2024 in #support-community
I'm getting null for getUserIdentity
Any clue why I keep getting null for getUserIdentity. Do I maybe just have something misconfigured? I'm using the next.js stuff
"use client";

import { ConvexAuthNextjsProvider } from "@convex-dev/auth/nextjs";
import { ReactNode } from "react";
import { ConvexReactClient } from "convex/react";

const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

export default function ConvexClientProvider({
children,
}: {
children: ReactNode;
}) {
return (
<ConvexAuthNextjsProvider client={convex}>
{children}
</ConvexAuthNextjsProvider>
);
}
"use client";

import { ConvexAuthNextjsProvider } from "@convex-dev/auth/nextjs";
import { ReactNode } from "react";
import { ConvexReactClient } from "convex/react";

const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

export default function ConvexClientProvider({
children,
}: {
children: ReactNode;
}) {
return (
<ConvexAuthNextjsProvider client={convex}>
{children}
</ConvexAuthNextjsProvider>
);
}
then I call an action
const generateVideoAction = useAction(api.videos.generateVideoAction);
const generateVideoAction = useAction(api.videos.generateVideoAction);
I'm logged in
export const generateVideoAction = action({
args: {
script: v.string(),
},
async handler(ctx, input) {
console.log(await ctx.auth.getUserIdentity());

export const generateVideoAction = action({
args: {
script: v.string(),
},
async handler(ctx, input) {
console.log(await ctx.auth.getUserIdentity());

this prints null
15 replies
CCConvex Community
Created by Web Dev Cody on 8/13/2024 in #support-community
How to know if authenticated in next client component?
I'm not sure if I misconfigured next.js and convex auth, but it seems like isAuthenticated never sets true for me. const { isAuthenticated } = useConvexAuth(); console.log("isAuthenticated", isAuthenticated); // always false I setup the auth with google, and I'm able to successfully go through the oauth flow and redirect back to my app.
9 replies
CCConvex Community
Created by Web Dev Cody on 7/19/2024 in #support-community
Does the scheduler only run one thing at a time?
No description
8 replies
CCConvex Community
Created by Web Dev Cody on 7/19/2024 in #support-community
Need help understanding the mutations and OCC
I'm working on a million checkboxes type of clone, and I have a function called toggleCheckbox which will first query a record, toggle a bit on or off in the number, and then write that number. This all seems to work fine. I'm also using another metadata table to keep a running sum of how many checkboxes are on or off. It seems like the counts are getting off for some reason. I created a cron which randomly toggles a bit using that same method described above every second in the first set of checkboxes. That also seems to work fine. The issue is when I manually start clicking checkboxes while the cron is running that my count seems to get off. I think there is something I'm not understanding about the concurrency model.
8 replies