@eleven-am/pondsocket 0.1.82 → 0.1.84

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.
Files changed (3) hide show
  1. package/nest.js +8 -6
  2. package/package.json +1 -1
  3. package/types.d.ts +8 -3
package/nest.js CHANGED
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.PondSocketModule = exports.Endpoints = exports.Endpoint = exports.Channel = exports.ChannelInstance = exports.OnConnectionRequest = exports.OnEvent = exports.OnJoinRequest = exports.GetConnectionQuery = exports.GetConnectionHeaders = exports.GetConnectionParams = exports.GetConnectionRequestId = exports.GetConnectionResponse = exports.GetConnectionRequest = exports.GetEventRequest = exports.GetEventResponse = exports.GetEventQuery = exports.GetEventParams = exports.GetEventPayload = exports.GetUserPresences = exports.GetInternalChannel = exports.GetUserData = exports.GetJoinParams = exports.GetJoinResponse = exports.GetJoinRequest = void 0;
24
+ const http_1 = require("http");
24
25
  const common_1 = require("@nestjs/common");
25
26
  require("reflect-metadata");
26
27
  const pondSocket_1 = require("./server/pondSocket");
@@ -460,14 +461,15 @@ const Endpoints = ({ endpoints, providers = [], imports = [], exports = [], }) =
460
461
  exports.Endpoints = Endpoints;
461
462
  class PondSocketModule {
462
463
  constructor(moduleRef, adapterHost) {
464
+ var _a;
463
465
  this.moduleRef = moduleRef;
464
466
  this.adapterHost = adapterHost;
465
- const expressInstance = this.adapterHost.httpAdapter;
466
- const server = expressInstance.getHttpServer();
467
- const socket = new pondSocket_1.PondSocket(server);
468
- expressInstance.listen = (...args) => {
469
- var _a;
470
- const endpoints = (_a = getClassMetadata(endpointsClassKey, this.constructor)) !== null && _a !== void 0 ? _a : [];
467
+ const httpAdapter = this.adapterHost.httpAdapter;
468
+ const endpoints = (_a = getClassMetadata(endpointsClassKey, this.constructor)) !== null && _a !== void 0 ? _a : [];
469
+ httpAdapter.listen = (...args) => {
470
+ const app = httpAdapter.getInstance();
471
+ const server = (0, http_1.createServer)(app);
472
+ const socket = new pondSocket_1.PondSocket(server);
471
473
  endpoints.forEach((endpoint) => this.manageEndpoint(socket, endpoint));
472
474
  return socket.listen(...args);
473
475
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.82",
3
+ "version": "0.1.84",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
package/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ModuleMetadata } from '@nestjs/common/interfaces/modules/module-metadata.interface';
2
1
  import { Server as HTTPServer, IncomingHttpHeaders } from 'http';
3
2
 
3
+ import { ModuleMetadata } from '@nestjs/common/interfaces/modules/module-metadata.interface';
4
4
  import type { ModuleRef, HttpAdapterHost } from '@nestjs/core';
5
5
  import type { Express } from 'express';
6
6
  import { WebSocketServer } from 'ws';
@@ -24,6 +24,11 @@ type Params<Path> = {
24
24
  [Key in FilteredParams<Path>]: string
25
25
  }
26
26
 
27
+ interface EndpointMetadata {
28
+ path?: string;
29
+ channels: Constructor<NonNullable<unknown>>[];
30
+ }
31
+
27
32
  type PondPath<Path extends string> = Path | RegExp;
28
33
 
29
34
  type EventParams<Path> = {
@@ -765,9 +770,9 @@ declare function Channels(channels: Constructor<NonNullable<unknown>>[]): ClassD
765
770
 
766
771
  /**
767
772
  * Decorator to mark a class as an endpoint.
768
- * @param path - The path for the endpoint (default is '*').
773
+ * @param metadata - The metadata for the endpoint.
769
774
  */
770
- declare function DEndpoint(path?: string): ClassDecorator;
775
+ declare function DEndpoint(metadata: EndpointMetadata): ClassDecorator;
771
776
 
772
777
  /**
773
778
  * Decorator to mark a class as having multiple endpoints.