Task 4: Upload Routes Extended - upload.js: Generate preview after single file upload - batchUpload.js: Generate previews for all batch uploads - Async preview generation (non-blocking response) - Auto-update preview_path in database after generation Task 5: Repository with preview_path - GroupRepository: Include preview_path in INSERT - getGroupById: Return previewPath in image objects - groupFormatter: Add previewPath to formatGroupDetail() - All queries now support preview_path column Task 6: API Endpoints Extended - Add PREVIEW_STATIC_DIRECTORY constant (/previews) - Serve preview images via express.static - All existing endpoints now return previewPath field - Fallback to filePath if preview not available (frontend)
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
const endpoints = {
|
|
UPLOAD_STATIC_DIRECTORY: '/upload',
|
|
UPLOAD_FILE: '/upload',
|
|
UPLOAD_BATCH: '/upload/batch',
|
|
PREVIEW_STATIC_DIRECTORY: '/previews',
|
|
DOWNLOAD_FILE: '/download/:id',
|
|
GET_GROUP: '/groups/:groupId',
|
|
GET_ALL_GROUPS: '/groups',
|
|
DELETE_GROUP: '/groups/:groupId'
|
|
};
|
|
|
|
// Filesystem directory (relative to backend/src) where uploaded images will be stored
|
|
// Use path.join(__dirname, '..', UPLOAD_FS_DIR, fileName) in code
|
|
const UPLOAD_FS_DIR = 'data/images';
|
|
|
|
// Filesystem directory (relative to backend/src) where preview images will be stored
|
|
// Use path.join(__dirname, '..', PREVIEW_FS_DIR, fileName) in code
|
|
const PREVIEW_FS_DIR = 'data/previews';
|
|
|
|
// Preview generation configuration
|
|
const PREVIEW_CONFIG = {
|
|
maxWidth: 800, // Maximum width in pixels
|
|
quality: 85, // JPEG quality (0-100)
|
|
format: 'jpeg' // Output format
|
|
};
|
|
|
|
const time = {
|
|
HOURS_24: 86400000,
|
|
WEEK_1: 604800000
|
|
};
|
|
|
|
module.exports = { endpoints, time, UPLOAD_FS_DIR, PREVIEW_FS_DIR, PREVIEW_CONFIG }; |