feat(storage): add shared R2 media proxy and orphan cleanup tooling for R2/Bunny

This commit is contained in:
Yusuf İpek
2026-02-24 17:02:54 +03:00
parent ffa55d7dcc
commit fa51847aa4
9 changed files with 703 additions and 172 deletions
+10 -8
View File
@@ -77,17 +77,19 @@ if (process.env.NODE_ENV !== 'production') {
globalForPrisma.prisma = db;
}
export async function disconnectDb(): Promise<void> {
if (globalForPool.pgPool) {
await globalForPool.pgPool.end();
globalForPool.pgPool = undefined;
}
await db.$disconnect();
}
// Graceful shutdown handler
async function shutdown() {
console.log('Shutting down database connections...');
if (globalForPool.pgPool) {
await globalForPool.pgPool.end();
console.log('Database pool closed');
}
await db.$disconnect();
console.log('Prisma client disconnected');
await disconnectDb();
console.log('Database connections closed');
}
// Register shutdown handlers