refactor: Move inline Zod schemas from routes to validator files
Create ai-kurzy.validators.js and service.validators.js with schemas extracted from their respective route files. Routes now import schemas instead of defining them inline. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,34 +6,19 @@ import { authenticate } from '../middlewares/auth/authMiddleware.js';
|
||||
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';
|
||||
import {
|
||||
serviceIdSchema,
|
||||
folderIdSchema,
|
||||
folderDocumentIdSchema,
|
||||
createFolderSchema,
|
||||
updateFolderSchema,
|
||||
} from '../validators/service.validators.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const upload = createUpload({ maxSizeMB: 50 });
|
||||
|
||||
const serviceIdSchema = z.object({
|
||||
serviceId: z.string().uuid(),
|
||||
});
|
||||
|
||||
const folderIdSchema = z.object({
|
||||
folderId: z.string().uuid(),
|
||||
});
|
||||
|
||||
const folderDocumentIdSchema = z.object({
|
||||
folderId: z.string().uuid(),
|
||||
documentId: z.string().uuid(),
|
||||
});
|
||||
|
||||
const createFolderSchema = z.object({
|
||||
name: z.string().min(1).max(255),
|
||||
});
|
||||
|
||||
const updateFolderSchema = z.object({
|
||||
name: z.string().min(1).max(255),
|
||||
});
|
||||
|
||||
// All service routes require authentication
|
||||
router.use(authenticate);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user