@nestjs/websockets
Advanced tools
Comparing version 5.4.1 to 5.5.0-0
import { WsExceptionsHandler } from '../exceptions/ws-exceptions-handler'; | ||
export declare class WsProxy { | ||
create(targetCallback: (...args) => Promise<void>, exceptionsHandler: WsExceptionsHandler): (...args) => Promise<void>; | ||
create(targetCallback: (...args) => Promise<any>, exceptionsHandler: WsExceptionsHandler): (...args) => Promise<any>; | ||
handleError<T>(exceptionsHandler: WsExceptionsHandler, args: any[], error: T): void; | ||
isObservable(result: any): boolean; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const shared_utils_1 = require("@nestjs/common/utils/shared.utils"); | ||
const execution_context_host_1 = require("@nestjs/core/helpers/execution-context.host"); | ||
const rxjs_1 = require("rxjs"); | ||
const operators_1 = require("rxjs/operators"); | ||
class WsProxy { | ||
@@ -8,11 +11,23 @@ create(targetCallback, exceptionsHandler) { | ||
try { | ||
return await targetCallback(...args); | ||
const result = await targetCallback(...args); | ||
return !this.isObservable(result) | ||
? result | ||
: result.pipe(operators_1.catchError(error => { | ||
this.handleError(exceptionsHandler, args, error); | ||
return rxjs_1.empty(); | ||
})); | ||
} | ||
catch (e) { | ||
const host = new execution_context_host_1.ExecutionContextHost(args); | ||
exceptionsHandler.handle(e, host); | ||
catch (error) { | ||
this.handleError(exceptionsHandler, args, error); | ||
} | ||
}; | ||
} | ||
handleError(exceptionsHandler, args, error) { | ||
const host = new execution_context_host_1.ExecutionContextHost(args); | ||
exceptionsHandler.handle(error, host); | ||
} | ||
isObservable(result) { | ||
return result && shared_utils_1.isFunction(result.subscribe); | ||
} | ||
} | ||
exports.WsProxy = WsProxy; |
{ | ||
"name": "@nestjs/websockets", | ||
"version": "5.4.1", | ||
"version": "5.5.0-0", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@websockets)", | ||
@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
54199
1025
2