0a9588abb7
- Add pagination support to findAll (page, limit query params) - Add findByTemplateId method to service - Add GET /by-template/:templateId endpoint to controller - Service already includes CRUD for QuestionBank and QuestionBankItem
26 lines
1.3 KiB
TypeScript
26 lines
1.3 KiB
TypeScript
|
|
export const DOC_EXTENSIONS = ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'rtf', 'csv', 'txt', 'md', 'html', 'json', 'xml', 'odt', 'ods', 'odp'];
|
|
export const CODE_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx', 'css', 'py', 'java', 'sql', 'cpp', 'h', 'go', 'rs', 'php', 'rb'];
|
|
export const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff'];
|
|
export const IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/bmp', 'image/webp', 'image/tiff'];
|
|
|
|
export const KB_ALLOWED_EXTENSIONS = [...DOC_EXTENSIONS, ...CODE_EXTENSIONS, ...IMAGE_EXTENSIONS];
|
|
export const GROUP_ALLOWED_EXTENSIONS = [...DOC_EXTENSIONS, ...CODE_EXTENSIONS, ...IMAGE_EXTENSIONS];
|
|
|
|
export const isExtensionAllowed = (ext: string, type: 'kb' | 'group'): boolean => {
|
|
const normalizedExt = ext.toLowerCase().replace('.', '');
|
|
if (type === 'kb') {
|
|
return KB_ALLOWED_EXTENSIONS.includes(normalizedExt);
|
|
}
|
|
return GROUP_ALLOWED_EXTENSIONS.includes(normalizedExt);
|
|
};
|
|
|
|
export const getSupportedFormatsLabel = (type: 'kb' | 'group'): string => {
|
|
return 'PDF, Word, Excel, PPT, TXT, MD, Code(JS/TS/PY...), Images...';
|
|
};
|
|
|
|
export const isFormatSupportedForPreview = (filename: string): boolean => {
|
|
const ext = filename.toLowerCase().split('.').pop() || '';
|
|
return [...DOC_EXTENSIONS, ...IMAGE_EXTENSIONS].includes(ext);
|
|
};
|