feldrok
feldrok
Explore posts from servers
TTCTheo's Typesafe Cult
Created by feldrok on 10/16/2024 in #questions
Uploadthing Delete Files
Hi, I'm trying to delete lots of files in one go using a cron job... I detect files that are more than 3 days old and delete all of them... I'm doing this:
const activityFilenamesToDelete = expiredActivityRecords.map(
(record) => record.filename,
);

const taskFilenamesToDelete = expiredTaskRecords.map(
(record) => record.evidence?.[0]?.filename,
);

const filenamesToDelete = [
...activityFilenamesToDelete,
...taskFilenamesToDelete,
];

if (filenamesToDelete.length > 0) {
try {
const validFilenamesToDelete = filenamesToDelete.filter(
(filename): filename is string => filename !== null,
);
await utapi.deleteFiles(validFilenamesToDelete);
console.log(
`Successfully deleted ${validFilenamesToDelete.length} expired files`,
);
} catch (error) {
console.error("Failed to delete expired files:", error);
}
}

return Response.json({ deletedCount: filenamesToDelete.length });
const activityFilenamesToDelete = expiredActivityRecords.map(
(record) => record.filename,
);

const taskFilenamesToDelete = expiredTaskRecords.map(
(record) => record.evidence?.[0]?.filename,
);

const filenamesToDelete = [
...activityFilenamesToDelete,
...taskFilenamesToDelete,
];

if (filenamesToDelete.length > 0) {
try {
const validFilenamesToDelete = filenamesToDelete.filter(
(filename): filename is string => filename !== null,
);
await utapi.deleteFiles(validFilenamesToDelete);
console.log(
`Successfully deleted ${validFilenamesToDelete.length} expired files`,
);
} catch (error) {
console.error("Failed to delete expired files:", error);
}
}

return Response.json({ deletedCount: filenamesToDelete.length });
  filename is the key of each, some are like this: "S3NUJszt9cEpdYb3l7F8xZGXwMvl7CkJ0qUjcYnNgiWe2mHb", some others like "ba8c9b9a-cda1-47b5-a972-ee1936c27a6c-wy6d.gif", i don't know why it's failing, but it may be because i'm trying to delete over 20k files... it doesn't throw an error, it just doesn't delete anything. please help
3 replies
TTCTheo's Typesafe Cult
Created by feldrok on 12/8/2023 in #questions
T3 Upgrade app
No description
3 replies
TTCTheo's Typesafe Cult
Created by feldrok on 5/26/2023 in #questions
Update Clerk Organization from TRPC Router
Hello, if anyone got an idea on how to handle this I would highly appreciate it. I have some organizations in my app and I have stored some information on the publicMetadata. I have a settings panel where an admin user will be able to change this information. I have read https://clerk.com/docs/nextjs/trpc as well as setting up the context like this project https://github.com/perkinsjr/t3-app-clerk-minimal/blob/main/src/server/api/trpc.ts, but i've not been able to figure it out... Would I need to make an axios request from inside the procedure? How would i go on about making this update procedure? I've tried a few ways without success, any guidance would be highly appreciated.
4 replies
TTCTheo's Typesafe Cult
Created by feldrok on 3/15/2023 in #questions
tRPC API endpoints?
Hello guys, i've been asked to implement an api route to create, validate and edit password using post methods, I'm allowed to use t3 and provide a better implementation with it... I'm new to it and i'm trying to wrap my mind around trpc, i have been able to do queries and mutations using it from the front end. but I'm not sure if it's possible to use it in an api endpoint ex: /api/user/create, sending a req.body instead of "input"? sorry im a bit lost
16 replies
TTCTheo's Typesafe Cult
Created by feldrok on 3/9/2023 in #questions
Error after clean setup of T3-TURBO-CLERK
4 replies