@nestjs/common 9.0.2 → 9.0.5

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.
@@ -1,9 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  import { Readable } from 'stream';
3
3
  import { StreamableFileOptions } from './streamable-options.interface';
4
+ export interface StreamableHandlerResponse {
5
+ statusCode: number;
6
+ send: (msg: string) => void;
7
+ }
4
8
  export declare class StreamableFile {
5
9
  readonly options: StreamableFileOptions;
6
10
  private readonly stream;
11
+ protected handleError: (err: Error, response: StreamableHandlerResponse) => void;
7
12
  constructor(buffer: Uint8Array, options?: StreamableFileOptions);
8
13
  constructor(readable: Readable, options?: StreamableFileOptions);
9
14
  getStream(): Readable;
@@ -12,4 +17,6 @@ export declare class StreamableFile {
12
17
  disposition: string;
13
18
  length: number;
14
19
  };
20
+ get errorHandler(): (err: Error, response: StreamableHandlerResponse) => void;
21
+ setErrorHandler(handler: (err: Error, response: StreamableHandlerResponse) => void): this;
15
22
  }
@@ -9,6 +9,10 @@ class StreamableFile {
9
9
  var _a;
10
10
  var _b;
11
11
  this.options = options;
12
+ this.handleError = (err, res) => {
13
+ res.statusCode = 400;
14
+ res.send(err.message);
15
+ };
12
16
  if (util_1.types.isUint8Array(bufferOrReadStream)) {
13
17
  this.stream = new stream_1.Readable();
14
18
  this.stream.push(bufferOrReadStream);
@@ -30,5 +34,12 @@ class StreamableFile {
30
34
  length,
31
35
  };
32
36
  }
37
+ get errorHandler() {
38
+ return this.handleError;
39
+ }
40
+ setErrorHandler(handler) {
41
+ this.handleError = handler;
42
+ return this;
43
+ }
33
44
  }
34
45
  exports.StreamableFile = StreamableFile;
@@ -28,7 +28,7 @@ export interface ConfigurableModuleAsyncOptions<ModuleOptions, FactoryClassMetho
28
28
  * Function returning options (or a Promise resolving to options) to configure the
29
29
  * cache module.
30
30
  */
31
- useFactory?: (...args: unknown[]) => Promise<ModuleOptions> | ModuleOptions;
31
+ useFactory?: (...args: any[]) => Promise<ModuleOptions> | ModuleOptions;
32
32
  /**
33
33
  * Dependencies that a Factory may inject.
34
34
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/common",
3
- "version": "9.0.2",
3
+ "version": "9.0.5",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@common)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "homepage": "https://nestjs.com",