@nestjs/common 11.0.18 → 11.0.20

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/common",
3
- "version": "11.0.18",
3
+ "version": "11.0.20",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@common)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "homepage": "https://nestjs.com",
@@ -20,6 +20,7 @@
20
20
  "dependencies": {
21
21
  "file-type": "20.4.1",
22
22
  "iterare": "1.2.1",
23
+ "load-esm": "1.0.2",
23
24
  "tslib": "2.8.1",
24
25
  "uid": "2.0.2"
25
26
  },
@@ -19,7 +19,6 @@ export type FileTypeValidatorOptions = {
19
19
  * @publicApi
20
20
  */
21
21
  export declare class FileTypeValidator extends FileValidator<FileTypeValidatorOptions, IFile> {
22
- constructor(validationOptions: FileTypeValidatorOptions);
23
22
  buildErrorMessage(file?: IFile): string;
24
23
  isValid(file?: IFile): Promise<boolean>;
25
24
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileTypeValidator = void 0;
4
4
  const file_validator_interface_1 = require("./file-validator.interface");
5
+ const load_esm_1 = require("load-esm");
5
6
  /**
6
7
  * Defines the built-in FileTypeValidator. It validates incoming files by examining
7
8
  * their magic numbers using the file-type package, providing more reliable file type validation
@@ -12,16 +13,6 @@ const file_validator_interface_1 = require("./file-validator.interface");
12
13
  * @publicApi
13
14
  */
14
15
  class FileTypeValidator extends file_validator_interface_1.FileValidator {
15
- constructor(validationOptions) {
16
- super(validationOptions);
17
- // check if file-type is installed
18
- try {
19
- require.resolve('file-type');
20
- }
21
- catch (e) {
22
- throw new Error(`FileTypeValidator requires the file-type package. Please install it: npm i file-type`);
23
- }
24
- }
25
16
  buildErrorMessage(file) {
26
17
  if (file?.mimetype) {
27
18
  return `Validation failed (current file type is ${file.mimetype}, expected type is ${this.validationOptions.fileType})`;
@@ -40,7 +31,7 @@ class FileTypeValidator extends file_validator_interface_1.FileValidator {
40
31
  return false;
41
32
  }
42
33
  try {
43
- const { fileTypeFromBuffer } = (await eval('import ("file-type")'));
34
+ const { fileTypeFromBuffer } = await (0, load_esm_1.loadEsm)('file-type');
44
35
  const fileType = await fileTypeFromBuffer(file.buffer);
45
36
  return (!!fileType && !!fileType.mime.match(this.validationOptions.fileType));
46
37
  }