feat: Implement file upload and management system

- Created database schema for files and file parts.
- Added API endpoint to create a new file and generate an upload token.
- Implemented API endpoint to complete file uploads and generate a download token.
- Developed cron job for cleaning up expired files and deleting associated Discord messages.
- Added API endpoint for soft deletion of files and their parts.
- Implemented API endpoint to fetch file metadata and parts for download.
- Created API endpoint to upload file parts to Discord.
- Developed a client-side download page to handle file decryption and assembly.
- Established database connection pooling for efficient database operations.
This commit is contained in:
2025-10-16 09:16:06 +02:00
parent 762f42a20e
commit 2f07f75088
12 changed files with 4573 additions and 103 deletions

17
src/lib/db.ts Normal file
View File

@@ -0,0 +1,17 @@
import mysql from 'mysql2/promise';
if (!process.env.DB_HOST || !process.env.DB_USER || !process.env.DB_PASSWORD || !process.env.DB_DATABASE) {
throw new Error('Please define all database environment variables in .env.local');
}
const pool = mysql.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0
});
export default pool;