@nestjs/websockets
Advanced tools
Comparing version 6.6.7 to 6.7.0
@@ -1,2 +0,2 @@ | ||
import { Controller } from '@nestjs/common/interfaces'; | ||
import { ContextType, Controller } from '@nestjs/common/interfaces'; | ||
import { GuardsConsumer } from '@nestjs/core/guards/guards-consumer'; | ||
@@ -23,3 +23,3 @@ import { GuardsContextCreator } from '@nestjs/core/guards/guards-context-creator'; | ||
getDataMetatype(instance: Controller, callback: (...args: any[]) => any): any; | ||
createGuardsFn(guards: any[], instance: Controller, callback: (...args: any[]) => any): Function | null; | ||
createGuardsFn<TContext extends ContextType = ContextType>(guards: any[], instance: Controller, callback: (...args: any[]) => any, contextType?: TContext): Function | null; | ||
} |
@@ -19,2 +19,3 @@ "use strict"; | ||
const exceptionHandler = this.exceptionFiltersContext.create(instance, callback, module); | ||
const contextType = 'ws'; | ||
const pipes = this.pipesCreator.create(instance, callback, module); | ||
@@ -24,3 +25,3 @@ const guards = this.guardsContextCreator.create(instance, callback, module); | ||
const interceptors = this.interceptorsContextCreator.create(instance, callback, module); | ||
const fnCanActivate = this.createGuardsFn(guards, instance, callback); | ||
const fnCanActivate = this.createGuardsFn(guards, instance, callback, contextType); | ||
const handler = (args) => async () => { | ||
@@ -33,3 +34,3 @@ const [client, data, ...params] = args; | ||
fnCanActivate && (await fnCanActivate(args)); | ||
return this.interceptorsConsumer.intercept(interceptors, args, instance, callback, handler(args)); | ||
return this.interceptorsConsumer.intercept(interceptors, args, instance, callback, handler(args), contextType); | ||
}, exceptionHandler); | ||
@@ -44,5 +45,5 @@ } | ||
} | ||
createGuardsFn(guards, instance, callback) { | ||
createGuardsFn(guards, instance, callback, contextType) { | ||
const canActivateFn = async (args) => { | ||
const canActivate = await this.guardsConsumer.tryActivate(guards, args, instance, callback); | ||
const canActivate = await this.guardsConsumer.tryActivate(guards, args, instance, callback, contextType); | ||
if (!canActivate) { | ||
@@ -49,0 +50,0 @@ throw new ws_exception_1.WsException(constants_2.FORBIDDEN_MESSAGE); |
@@ -26,2 +26,3 @@ "use strict"; | ||
const host = new execution_context_host_1.ExecutionContextHost(args); | ||
host.setType('ws'); | ||
exceptionsHandler.handle(error, host); | ||
@@ -28,0 +29,0 @@ } |
{ | ||
"name": "@nestjs/websockets", | ||
"version": "6.6.7", | ||
"version": "6.7.0", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@websockets)", | ||
@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec", |
@@ -42,3 +42,3 @@ <p align="center"> | ||
With official support, you can get expert help straight from Nest core team. We provide dedicated technical support, migration strategies, advice on best practices (and design decisions), PR reviews, and team augmentation. Read more about [support here](https://docs.nestjs.com/enterprise). | ||
With official support, you can get expert help straight from Nest core team. We provide dedicated technical support, migration strategies, advice on best practices (and design decisions), PR reviews, and team augmentation. Read more about [support here](https://enterprise.nestjs.com). | ||
@@ -72,3 +72,4 @@ ## Support | ||
<a href="https://www.codeguesser.co.uk" target="_blank"><img src="https://nestjs.com/img/codeguesser-logo.svg" width="120" valign="middle" /></a> | ||
<a href="https://tekhattan.com" target="_blank"><img src="https://nestjs.com/img/tekhattan-logo.png" width="110" valign="middle" /></a> | ||
<a href="https://tekhattan.com" target="_blank"><img src="https://nestjs.com/img/tekhattan-logo.png" width="110" valign="middle" /></a> | ||
<a href="https://f-a.nz/" target="_blank"><img src="https://nestjs.com/img/franz.svg" width="80" valign="middle" /></a> | ||
@@ -75,0 +76,0 @@ |
58879
928
88