feat: display user's posts on profile page

This commit is contained in:
Stevan Freeborn
2023-09-11 00:40:14 -05:00
parent 8b350c9809
commit 4b74f47e75
18 changed files with 397 additions and 67 deletions
+22
View File
@@ -0,0 +1,22 @@
import { auth } from '@clerk/nextjs';
import { ConvexHttpClient } from 'convex/browser';
export async function getConvexClient() {
const { user, getToken } = auth();
const token = await getToken({ template: 'convex' });
if (token === null || user === null) {
throw new Error('NOT_AUTHORIZED');
}
const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL;
if (CONVEX_URL === undefined) {
throw new Error('NEXT_PUBLIC_CONVEX_URL is undefined');
}
const client = new ConvexHttpClient(CONVEX_URL);
client.setAuth(token);
return client;
}