@tc-libs/file 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +77 -11
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,11 +1,77 @@
1
- # file
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Building
6
-
7
- Run `nx build file` to build the library.
8
-
9
- ## Running unit tests
10
-
11
- Run `nx test file` to execute the unit tests via [Jest](https://jestjs.io).
1
+ # @tc-libs/file
2
+
3
+ Toolkit upload/validazione file per NestJS.
4
+
5
+ Il package include:
6
+
7
+ - `FileModule`
8
+ - decorator upload
9
+ - pipe MIME/type/size/max-files
10
+ - interceptor per limiti custom
11
+ - DTO per Swagger multipart
12
+
13
+ ## Registrazione
14
+
15
+ ```ts
16
+ FileModule.register(
17
+ {
18
+ image: { maxFiles: 5, maxFileSize: 5_000_000 },
19
+ excel: { maxFiles: 1, maxFileSize: 10_000_000 },
20
+ audio: { maxFiles: 1, maxFileSize: 20_000_000 },
21
+ video: { maxFiles: 1, maxFileSize: 100_000_000 },
22
+ },
23
+ true,
24
+ );
25
+ ```
26
+
27
+ ## Decorator
28
+
29
+ - `UploadFileSingle(field)`
30
+ - `UploadFileMultiple(field)`
31
+ - `FileCustomMaxFile(n)`
32
+ - `FileCustomMaxSize('20MB')`
33
+ - `FilePartNumber()`
34
+
35
+ Esempio:
36
+
37
+ ```ts
38
+ @Post('avatar')
39
+ @UploadFileSingle('file')
40
+ @FileCustomMaxSize('10MB')
41
+ upload(@UploadedFile(FileTypeImagePipe, FileSizeImagePipe) file: IFile) {}
42
+ ```
43
+
44
+ ## Pipe principali
45
+
46
+ - `FileTypeImagePipe`
47
+ - `FileTypeVideoPipe`
48
+ - `FileTypeAudioPipe`
49
+ - `FileTypeExcelPipe`
50
+ - `FileTypeVideoAudioTextPipe`
51
+ - `FileSizeImagePipe`
52
+ - `FileSizeVideoPipe`
53
+ - `FileSizeAudioPipe`
54
+ - `FileSizeExcelPipe`
55
+ - `FileRequiredPipe`
56
+ - `FileMaxFilesPipe`
57
+
58
+ Questi pipe usano le costanti di `@tc-libs/constant` e lanciano errori di `@tc-libs/errors`.
59
+
60
+ ## Tipi utili
61
+
62
+ ```ts
63
+ type IFile = {
64
+ fieldname: string;
65
+ originalname: string;
66
+ mimetype: string;
67
+ buffer: Buffer;
68
+ size: number;
69
+ };
70
+ ```
71
+
72
+ ## Sviluppo
73
+
74
+ ```bash
75
+ nx build file
76
+ nx test file
77
+ ```
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@tc-libs/file",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "dependencies": {
5
- "@tc-libs/request": "3.6.0",
6
- "@tc-libs/errors": "3.6.0",
7
- "@tc-libs/constant": "3.6.0",
5
+ "@tc-libs/request": "3.8.0",
6
+ "@tc-libs/errors": "3.8.0",
7
+ "@tc-libs/constant": "3.8.0",
8
8
  "@nestjs/common": "^11.0.12",
9
9
  "@nestjs/platform-express": "^11.0.12",
10
10
  "@nestjs/swagger": "^11.1.0",