Skip to content

Commit d9a69a3

Browse files
chore(common): temporarily move file-type to regular deps
1 parent 55ca078 commit d9a69a3

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

packages/common/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
},
1919
"license": "MIT",
2020
"dependencies": {
21+
"file-type": "20.4.1",
2122
"iterare": "1.2.1",
2223
"tslib": "2.8.1",
2324
"uid": "2.0.2"
2425
},
2526
"peerDependencies": {
2627
"class-transformer": "*",
2728
"class-validator": "*",
28-
"file-type": "^20.4.1",
2929
"reflect-metadata": "^0.1.12 || ^0.2.0",
3030
"rxjs": "^7.1.0"
3131
},
@@ -35,9 +35,6 @@
3535
},
3636
"class-transformer": {
3737
"optional": true
38-
},
39-
"file-type": {
40-
"optional": true
4138
}
4239
}
4340
}

packages/common/pipes/file/file-type.validator.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ export class FileTypeValidator extends FileValidator<
2525
FileTypeValidatorOptions,
2626
IFile
2727
> {
28+
constructor(validationOptions: FileTypeValidatorOptions) {
29+
super(validationOptions);
30+
31+
// check if file-type is installed
32+
try {
33+
require.resolve('file-type');
34+
} catch (e) {
35+
throw new Error(
36+
`FileTypeValidator requires the file-type package. Please install it: npm i file-type`,
37+
);
38+
}
39+
}
40+
2841
buildErrorMessage(file?: IFile): string {
2942
if (file?.mimetype) {
3043
return `Validation failed (current file type is ${file.mimetype}, expected type is ${this.validationOptions.fileType})`;

sample/01-cats-app/src/common/pipes/parse-int.pipe.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
2+
ArgumentMetadata,
23
BadRequestException,
3-
PipeTransform,
44
Injectable,
5-
ArgumentMetadata,
5+
PipeTransform,
66
} from '@nestjs/common';
77

88
@Injectable()

0 commit comments

Comments
 (0)