Replaces local filesystem document storage with S3-compatible object storage. Adds embedded SeaweedFS 'weed mini' for local development and Docker deployments. Updates document upload flow to use presigned URLs with a server fallback proxy. Refactors auth configuration to use BASE_URL and AUTH_SECRET. BREAKING CHANGE: Renamed BETTER_AUTH_URL to BASE_URL and BETTER_AUTH_SECRET to AUTH_SECRET. Removed legacy document upload/content endpoints. Requires S3 environment variables (auto-configured for embedded SeaweedFS).
15 lines
535 B
TypeScript
15 lines
535 B
TypeScript
import path from 'path';
|
|
import type { DocumentType } from '@/types/documents';
|
|
|
|
export function safeDocumentName(rawName: string, fallback: string): string {
|
|
const baseName = path.basename(rawName || fallback);
|
|
return baseName.replaceAll('\u0000', '').slice(0, 240) || fallback;
|
|
}
|
|
|
|
export function toDocumentTypeFromName(name: string): DocumentType {
|
|
const ext = path.extname(name).toLowerCase();
|
|
if (ext === '.pdf') return 'pdf';
|
|
if (ext === '.epub') return 'epub';
|
|
if (ext === '.docx') return 'docx';
|
|
return 'html';
|
|
}
|