refactor: Extract shared multer/upload config from routes
Create src/config/upload.js with createUpload() factory and shared ALLOWED_FILE_TYPES constant. Replace duplicated multer configs in 5 route files with calls to the shared factory. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import express from 'express';
|
||||
import multer from 'multer';
|
||||
import * as serviceController from '../controllers/service.controller.js';
|
||||
import * as serviceFolderController from '../controllers/service-folder.controller.js';
|
||||
import * as serviceDocumentController from '../controllers/service-document.controller.js';
|
||||
@@ -8,13 +7,11 @@ import { requireAdmin } from '../middlewares/auth/roleMiddleware.js';
|
||||
import { validateBody, validateParams } from '../middlewares/security/validateInput.js';
|
||||
import { createServiceSchema, updateServiceSchema } from '../validators/crm.validators.js';
|
||||
import { z } from 'zod';
|
||||
import { createUpload } from '../config/upload.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const upload = multer({
|
||||
storage: multer.memoryStorage(),
|
||||
limits: { fileSize: 50 * 1024 * 1024 }, // 50MB limit
|
||||
});
|
||||
const upload = createUpload({ maxSizeMB: 50 });
|
||||
|
||||
const serviceIdSchema = z.object({
|
||||
serviceId: z.string().uuid(),
|
||||
|
||||
Reference in New Issue
Block a user