@nestjs/common
Advanced tools
Comparing version 10.2.7 to 10.2.8
/// <reference types="node" /> | ||
import { Readable } from 'stream'; | ||
import { StreamableFileOptions, StreamableHandlerResponse } from './interfaces'; | ||
import { Logger } from '../services'; | ||
/** | ||
@@ -12,3 +13,5 @@ * @see [Streaming files](https://docs.nestjs.com/techniques/streaming-files) | ||
private readonly stream; | ||
protected logger: Logger; | ||
protected handleError: (err: Error, response: StreamableHandlerResponse) => void; | ||
protected logError: (err: Error) => void; | ||
constructor(buffer: Uint8Array, options?: StreamableFileOptions); | ||
@@ -24,2 +27,4 @@ constructor(readable: Readable, options?: StreamableFileOptions); | ||
setErrorHandler(handler: (err: Error, response: StreamableHandlerResponse) => void): this; | ||
get errorLogger(): (err: Error) => void; | ||
setErrorLogger(handler: (err: Error) => void): this; | ||
} |
@@ -8,2 +8,3 @@ "use strict"; | ||
const shared_utils_1 = require("../utils/shared.utils"); | ||
const services_1 = require("../services"); | ||
/** | ||
@@ -17,2 +18,3 @@ * @see [Streaming files](https://docs.nestjs.com/techniques/streaming-files) | ||
this.options = options; | ||
this.logger = new services_1.Logger('StreamableFile'); | ||
this.handleError = (err, res) => { | ||
@@ -29,2 +31,5 @@ if (res.destroyed) { | ||
}; | ||
this.logError = (err) => { | ||
this.logger.error(err.message, err.stack); | ||
}; | ||
if (util_1.types.isUint8Array(bufferOrReadStream)) { | ||
@@ -58,3 +63,10 @@ this.stream = new stream_1.Readable(); | ||
} | ||
get errorLogger() { | ||
return this.logError; | ||
} | ||
setErrorLogger(handler) { | ||
this.logError = handler; | ||
return this; | ||
} | ||
} | ||
exports.StreamableFile = StreamableFile; |
{ | ||
"name": "@nestjs/common", | ||
"version": "10.2.7", | ||
"version": "10.2.8", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@common)", | ||
@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec", |
@@ -109,3 +109,3 @@ "use strict"; | ||
} | ||
const types = [String, Boolean, Number, Array, Object, Buffer]; | ||
const types = [String, Boolean, Number, Array, Object, Buffer, Date]; | ||
return !types.some(t => metatype === t) && !(0, shared_utils_1.isNil)(metatype); | ||
@@ -112,0 +112,0 @@ } |
@@ -148,8 +148,15 @@ "use strict"; | ||
stringifyMessage(message, logLevel) { | ||
// If the message is a function, call it and re-resolve its value. | ||
return (0, shared_utils_1.isFunction)(message) | ||
? this.stringifyMessage(message(), logLevel) | ||
: (0, shared_utils_1.isPlainObject)(message) || Array.isArray(message) | ||
? `${this.colorize('Object:', logLevel)}\n${JSON.stringify(message, (key, value) => typeof value === 'bigint' ? value.toString() : value, 2)}\n` | ||
: this.colorize(message, logLevel); | ||
if ((0, shared_utils_1.isFunction)(message)) { | ||
const messageAsStr = Function.prototype.toString.call(message); | ||
const isClass = messageAsStr.startsWith('class '); | ||
if (isClass) { | ||
// If the message is a class, we will display the class name. | ||
return this.stringifyMessage(message.name, logLevel); | ||
} | ||
// If the message is a non-class function, call it and re-resolve its value. | ||
return this.stringifyMessage(message(), logLevel); | ||
} | ||
return (0, shared_utils_1.isPlainObject)(message) || Array.isArray(message) | ||
? `${this.colorize('Object:', logLevel)}\n${JSON.stringify(message, (key, value) => typeof value === 'bigint' ? value.toString() : value, 2)}\n` | ||
: this.colorize(message, logLevel); | ||
} | ||
@@ -156,0 +163,0 @@ colorize(message, logLevel) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
426510
9924