Bumble
Bumble
TTCTheo's Typesafe Cult
Created by Satou kuzuma on 3/29/2024 in #questions
table schema admins table
I would actually make both. Having a separate table for each role makes it flexible to add more columns to each role individually. Also having one large table means you could share common columns like name, image, etc. In the end, it depends on your app and what it requires.
3 replies
TTCTheo's Typesafe Cult
Created by Noor on 3/11/2024 in #questions
Change BG using React State
You should store the state in a global element like the dom or global state so it does not depend on the path.
4 replies
TTCTheo's Typesafe Cult
Created by tsuki on 3/12/2024 in #questions
Properly setting a minimum delay when fetching data from external api
await new Promise((resolve) => setTimeout(resolve, 150));
await new Promise((resolve) => setTimeout(resolve, 150));
Adding this, will delay whatever is happening by 150ms. May I ask why do you want to fetch data more than 10 times a second?
4 replies
TTCTheo's Typesafe Cult
Created by kirentanna on 3/2/2024 in #questions
Uploadthing uploading directly from express server
import { UTApi } from "uploadthing/server";

const utapi = new UTApi();

// Upload image to UT
const metadata = {};
const uploadResponse = await utapi.uploadFiles(new File([<binary image>], <image name>), { metadata });

// handle upload error
if (uploadResponse.error) {
// handle error
}

// handle upload success
const uploadedImg = uploadResponse.data;
import { UTApi } from "uploadthing/server";

const utapi = new UTApi();

// Upload image to UT
const metadata = {};
const uploadResponse = await utapi.uploadFiles(new File([<binary image>], <image name>), { metadata });

// handle upload error
if (uploadResponse.error) {
// handle error
}

// handle upload success
const uploadedImg = uploadResponse.data;
Make sure to replace <binary image> and <image name> with the correct values. Upload thing server api documentation https://docs.uploadthing.com/api-reference/ut-api#utapi
3 replies
TTCTheo's Typesafe Cult
Created by plyglt on 12/25/2022 in #questions
How to handle Failing Unique Constraints?
You can try/catch and check for this error (check docs for exact error code) and handle as you want. The most common approach is to try to read a record from the db with this id. If it returns something, then generate a new one. If it doesn't, you can safely insert it into db.
4 replies
TTCTheo's Typesafe Cult
Created by Huge Letters on 3/8/2024 in #questions
onUploadComplete and onUploadError
I had the same issue a couple of days ago, had to work around it. It'd be nice if they add this feature.
3 replies
TTCTheo's Typesafe Cult
Created by Mocha on 3/5/2024 in #questions
TRPCClientError: Unexpected token 'A', "An error o"... is not valid JSON
I meant middleware.ts at the root of your project. Make sure the request actually gets to your trpc handler. When I got this error, middleware.ts was redirecting requests to sign in page.
10 replies
TTCTheo's Typesafe Cult
Created by Mocha on 3/5/2024 in #questions
TRPCClientError: Unexpected token 'A', "An error o"... is not valid JSON
maybe it has something to do with your middleware file?
10 replies