- added LicenseController.ts and MimetypeController for enabling mime_types and licences
Some checks failed
CI Pipeline / japa-tests (push) Failing after 58s

- add new authors and contributors only by unique email addresses
- allow multiple file upload
- added validation rule for validating length of uploaded files
- modified Dockerfile for starting "bin/server.js" instead of *server.js"
- npm updates
This commit is contained in:
Kaimbacher 2024-06-14 12:38:04 +02:00
parent 770e791613
commit ac473b1e72
27 changed files with 1720 additions and 914 deletions

View file

@ -0,0 +1,51 @@
/*
|--------------------------------------------------------------------------
| Preloaded File - node ace make:preload rules/translatedLanguage
|--------------------------------------------------------------------------
|*/
import { FieldContext } from '@vinejs/vine/types';
import vine from '@vinejs/vine';
// import { VineString } from '@vinejs/vine';
import { VineMultipartFile, isBodyParserFile } from '#providers/vinejs_provider';
import type { MultipartFile } from '@adonisjs/core/bodyparser';
/**
* Options accepted by the unique rule
*/
// type Options = {
// mainLanguageField: string;
// typeField: string;
// };
type Options = {
// size: string | number;
// extnames: string[];
clientNameSizeLimit: number
};
async function filenameLength(file: VineMultipartFile | unknown, options: Options, field: FieldContext) {
// if (typeof value !== 'string' && typeof value != 'number') {
// return;
// }
if (!isBodyParserFile(file)) {
return;
}
const validatedFile = file as MultipartFile;
if (validatedFile.clientName.length > options.clientNameSizeLimit) {
field.report(`Filename length should be less or equal than ${options.clientNameSizeLimit} characters`, 'filenameLength', field);
}
}
export const filenameLengthRule = vine.createRule(filenameLength);
declare module '#providers/vinejs_provider' {
interface VineMultipartFile {
filenameLength(options: Options): this;
}
}
VineMultipartFile.macro('filenameLength', function (this: VineMultipartFile, options: Options) {
return this.use(filenameLengthRule(options));
});