Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nestjs/websockets

Package Overview
Dependencies
Maintainers
1
Versions
342
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/websockets - npm Package Compare versions

Comparing version 6.0.0-alpha.3 to 6.0.0-alpha.4

4

container.d.ts
import { ObservableSocketServer } from './interfaces';
export declare class SocketsContainer {
private readonly observableServers;
getAllServers(): Map<string, ObservableSocketServer>;
getAllServers(): Map<string | RegExp, ObservableSocketServer>;
getServerByPort(port: number): ObservableSocketServer;
addServer(namespace: string, port: number, server: ObservableSocketServer): void;
addServer(namespace: string | RegExp, port: number, server: ObservableSocketServer): void;
clear(): void;
}
export interface GatewayMetadata {
namespace?: string;
namespace?: string | RegExp;
path?: string;

@@ -4,0 +4,0 @@ serveClient?: boolean;

{
"name": "@nestjs/websockets",
"version": "6.0.0-alpha.3",
"version": "6.0.0-alpha.4",
"description": "Nest - modern, fast, powerful node.js web framework (@websockets)",

@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec",

@@ -19,2 +19,3 @@ <p align="center">

<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
<a href="https://discord.gg/G7Qnnhy"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>

@@ -52,15 +53,20 @@ <a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>

#### Gold Sponsors
#### Base Sponsor
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="220" /></a>
<a href="https://blueanchor.io/"><img src="https://nestjs.com/img/blueanchor.png" width="300" /></a> &nbsp;
<a href="https://www.novologic.com/"><img src="https://nestjs.com/img/novologic.png" width="200" /></a>
#### Silver Sponsors
<a href="https://neoteric.eu/"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" /></a> &nbsp;
<a href="http://gojob.com"><img src="http://nestjs.com/img/gojob-logo.png" valign="bottom" height="95" /></a> &nbsp; <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /> </a>
<a href="https://neoteric.eu/"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> &nbsp;
<a href="http://gojob.com"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" height="95" /></a> &nbsp; <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" valign="middle" /> </a> &nbsp; &nbsp;
<a href="https://yakaz.com/"><img src="https://nestjs.com/img/yakaz.png" width="100" valign="middle" /></a>
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="150" valign="middle" /></a>
#### Sponsors
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a> &nbsp; <a href="https://genuinebee.com/"><img src="https://nestjs.com/img/genuinebee.svg" height="38" /></a> &nbsp; <a href="http://architectnow.net/"><img src="https://nestjs.com/img/architectnow.png" height="24" /></a> &nbsp; <a href="https://quander.io/"><img src="https://nestjs.com/img/quander.png" height="28" /></a>
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" valign="middle" /></a> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" valign="middle" /></a> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" valign="middle" /></a> &nbsp; <a href="https://genuinebee.com/"><img src="https://nestjs.com/img/genuinebee.svg" height="38" valign="middle" /></a> &nbsp; <a href="http://architectnow.net/"><img src="https://nestjs.com/img/architectnow.png" height="24" valign="middle" /></a> &nbsp; <a href="https://quander.io/"><img src="https://nestjs.com/img/quander.png" height="28" valign="middle" /></a> &nbsp; <a href="https://mantro.net/"><img src="https://nestjs.com/img/mantro-logo.svg" height="20" valign="middle" /></a> &nbsp;
<a href="https://triplebyte.com/"><img src="https://nestjs.com/img/triplebyte.png" height="30" valign="middle" /></a>
## Backers

@@ -67,0 +73,0 @@

@@ -5,11 +5,14 @@ import { Injectable } from '@nestjs/common/interfaces/injectable.interface';

import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
export declare class SocketModule {
export declare class SocketModule<HttpServer = any> {
private readonly socketsContainer;
private applicationConfig;
private webSocketsController;
register(container: NestContainer, config: ApplicationConfig): void;
mergeAllGateways(providers: Map<string, InstanceWrapper<Injectable>>, moduleName: string): void;
mergeGatewayAndServer(wrapper: InstanceWrapper<Injectable>, moduleName: string): void;
private isAdapterInitialized;
private httpServer;
register(container: NestContainer, config: ApplicationConfig, httpServer?: HttpServer): void;
combineAllGateways(providers: Map<string, InstanceWrapper<Injectable>>, moduleName: string): void;
combineGatewayAndServer(wrapper: InstanceWrapper<Injectable>, moduleName: string): void;
close(): Promise<any>;
private initializeAdapter;
private getContextCreator;
}

@@ -5,2 +5,3 @@ "use strict";

const guards_context_creator_1 = require("@nestjs/core/guards/guards-context-creator");
const load_adapter_1 = require("@nestjs/core/helpers/load-adapter");
const interceptors_consumer_1 = require("@nestjs/core/interceptors/interceptors-consumer");

@@ -22,18 +23,18 @@ const interceptors_context_creator_1 = require("@nestjs/core/interceptors/interceptors-context-creator");

}
register(container, config) {
register(container, config, httpServer) {
this.applicationConfig = config;
this.httpServer = httpServer;
const contextCreator = this.getContextCreator(container);
const serverProvider = new socket_server_provider_1.SocketServerProvider(this.socketsContainer, config);
const contextCreator = this.getContextCreator(container);
this.webSocketsController = new web_sockets_controller_1.WebSocketsController(serverProvider, config, contextCreator);
const modules = container.getModules();
modules.forEach(({ providers }, moduleName) => this.mergeAllGateways(providers, moduleName));
modules.forEach(({ providers }, moduleName) => this.combineAllGateways(providers, moduleName));
}
mergeAllGateways(providers, moduleName) {
providers.forEach(wrapper => this.mergeGatewayAndServer(wrapper, moduleName));
combineAllGateways(providers, moduleName) {
[...providers.values()]
.filter(wrapper => wrapper && !wrapper.isNotMetatype)
.forEach(wrapper => this.combineGatewayAndServer(wrapper, moduleName));
}
mergeGatewayAndServer(wrapper, moduleName) {
const { instance, metatype, isNotMetatype } = wrapper;
if (isNotMetatype) {
return;
}
combineGatewayAndServer(wrapper, moduleName) {
const { instance, metatype } = wrapper;
const metadataKeys = Reflect.getMetadataKeys(metatype);

@@ -43,2 +44,5 @@ if (!metadataKeys.includes(constants_1.GATEWAY_METADATA)) {

}
if (!this.isAdapterInitialized) {
this.initializeAdapter();
}
this.webSocketsController.mergeGatewayAndServer(instance, metatype, moduleName);

@@ -48,9 +52,25 @@ }

if (!this.applicationConfig) {
return undefined;
return;
}
const adapter = this.applicationConfig.getIoAdapter();
if (!adapter) {
return;
}
const servers = this.socketsContainer.getAllServers();
await Promise.all(iterare_1.default(servers.values()).map(async ({ server }) => server && adapter.close(server)));
await Promise.all(iterare_1.default(servers.values())
.filter(({ server }) => server)
.map(async ({ server }) => adapter.close(server)));
this.socketsContainer.clear();
}
initializeAdapter() {
const adapter = this.applicationConfig.getIoAdapter();
if (adapter) {
this.isAdapterInitialized = true;
return;
}
const { IoAdapter } = load_adapter_1.loadAdapter('@nestjs/platform-socket.io', 'WebSockets');
const ioAdapter = new IoAdapter(this.httpServer);
this.applicationConfig.setIoAdapter(ioAdapter);
this.isAdapterInitialized = true;
}
getContextCreator(container) {

@@ -57,0 +77,0 @@ return new ws_context_creator_1.WsContextCreator(new ws_proxy_1.WsProxy(), new exception_filters_context_1.ExceptionFiltersContext(container), new pipes_context_creator_1.PipesContextCreator(container), new pipes_consumer_1.PipesConsumer(), new guards_context_creator_1.GuardsContextCreator(container), new guards_consumer_1.GuardsConsumer(), new interceptors_context_creator_1.InterceptorsContextCreator(container), new interceptors_consumer_1.InterceptorsConsumer());

@@ -13,2 +13,3 @@ "use strict";

const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const util_1 = require("util");
const observable_socket_1 = require("./observable-socket");

@@ -49,2 +50,5 @@ class SocketServerProvider {

validateNamespace(namespace) {
if (!util_1.isString(namespace)) {
return namespace;
}
return shared_utils_1.validatePath(namespace);

@@ -51,0 +55,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc