chore: relocate backend into apps/api ahead of monorepo merge

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-24 12:20:40 +08:00
co-authored by Claude Sonnet 5
parent af44598df6
commit eaa6d2276a
388 changed files with 0 additions and 13998 deletions
@@ -0,0 +1,50 @@
/***********************************************************************************************************************************************************************
* File Name: taskUpload.middleware.js
* Type of Program: Middleware
* Description: Multer config for task completion file uploads.
* Uses memory storage — buffer is passed directly to S3.
* Single file per request (matches the two-step upload flow in
* ViewTaskDetails where each file is uploaded individually).
*
* Limits:
* fileSize: 500 MB (matches FileUpload.jsx DEFAULT_MAX_BYTES)
*
* Author: rgrgogu
* Date Created: Jun. 13, 2026
***********************************************************************************************************************************************************************/
const multer = require('multer');
const storage = multer.memoryStorage();
const upload = multer({
storage,
limits: {
fileSize: 500 * 1024 * 1024, // 500 MB
},
});
// Single file per request — field name must be "file"
const uploadTaskFile = upload.single('file');
// ─── Error wrapper ────────────────────────────────────────────────────────────
// Converts multer errors to a consistent R.error-style response.
const handleUpload = (req, res, next) => {
uploadTaskFile(req, res, (err) => {
if (!err) return next();
if (err.code === 'LIMIT_FILE_SIZE') {
return res.status(400).json({
status: 'error',
message: 'File exceeds the 500 MB size limit.',
});
}
console.error('[MULTER ERROR]', err);
return res.status(400).json({
status: 'error',
message: err.message ?? 'File upload failed.',
});
});
};
module.exports = { handleUpload };