Implement file storage layer with local provider, upload/download API, tests
- StorageProvider interface with LocalProvider (S3 placeholder) - File table with entity_type/entity_id references, content type, path - POST /v1/files (multipart upload), GET /v1/files (list by entity), GET /v1/files/:id (metadata), GET /v1/files/serve/* (content), DELETE /v1/files/:id - member_identifier drops base64 columns, uses file_id FKs - File validation: type whitelist, size limits, per-entity max - Fastify storage plugin injects provider into app - 6 API tests for upload, list, get, delete, validation - Test runner kills stale port before starting backend
This commit is contained in:
@@ -77,7 +77,16 @@ async function setupDatabase() {
|
||||
}
|
||||
|
||||
// --- Start backend ---
|
||||
async function killPort(port: number) {
|
||||
try {
|
||||
const { execSync } = await import('child_process')
|
||||
execSync(`lsof -ti:${port} | xargs kill -9 2>/dev/null || true`, { stdio: 'pipe' })
|
||||
await new Promise((r) => setTimeout(r, 1000))
|
||||
} catch {}
|
||||
}
|
||||
|
||||
async function startBackend(): Promise<Subprocess> {
|
||||
await killPort(TEST_PORT)
|
||||
const proc = spawn({
|
||||
cmd: ['bun', 'run', 'src/main.ts'],
|
||||
cwd: new URL('..', import.meta.url).pathname,
|
||||
@@ -90,6 +99,7 @@ async function startBackend(): Promise<Subprocess> {
|
||||
HOST: '0.0.0.0',
|
||||
NODE_ENV: 'development',
|
||||
LOG_LEVEL: 'error',
|
||||
STORAGE_LOCAL_PATH: '/tmp/forte-test-files',
|
||||
},
|
||||
stdout: 'pipe',
|
||||
stderr: 'pipe',
|
||||
|
||||
Reference in New Issue
Block a user