@eleven-am/pondsocket 0.1.83 → 0.1.85
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.
- package/nest.js +8 -6
- package/package.json +1 -1
- package/types.d.ts +16 -6
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
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const
|
|
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
package/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server as HTTPServer, IncomingHttpHeaders } from 'http';
|
|
2
2
|
|
|
3
|
-
import { ModuleMetadata } from '@nestjs/common
|
|
3
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
4
4
|
import type { ModuleRef, HttpAdapterHost } from '@nestjs/core';
|
|
5
5
|
import type { Express } from 'express';
|
|
6
6
|
import { WebSocketServer } from 'ws';
|
|
@@ -20,6 +20,16 @@ type FilteredParams<Path> = Path extends `${infer First}/${infer Second}`
|
|
|
20
20
|
? IsParam<First> | FilteredParams<Second>
|
|
21
21
|
: IsParam<Path>
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @desc The type for the params in a request
|
|
25
|
+
* @typeParam Path - The path to get the params from
|
|
26
|
+
* @example
|
|
27
|
+
*
|
|
28
|
+
* const params: Params<'/api/:id'> = {
|
|
29
|
+
* id: '123',
|
|
30
|
+
* foo: 'bar', // Error: Type 'string' is not assignable to type 'undefined'
|
|
31
|
+
* }
|
|
32
|
+
*/
|
|
23
33
|
type Params<Path> = {
|
|
24
34
|
[Key in FilteredParams<Path>]: string
|
|
25
35
|
}
|
|
@@ -677,13 +687,13 @@ declare function GetEventPayload(): ParameterDecorator;
|
|
|
677
687
|
|
|
678
688
|
/**
|
|
679
689
|
* @desc The Decorator for retrieving the EventRequest Params object from the request in a handler
|
|
680
|
-
* @returns {
|
|
690
|
+
* @returns {Params}
|
|
681
691
|
*/
|
|
682
692
|
declare function GetEventParams(): ParameterDecorator;
|
|
683
693
|
|
|
684
694
|
/**
|
|
685
695
|
* @desc The Decorator for retrieving the EventRequest Query object from the request in a handler
|
|
686
|
-
* @returns {
|
|
696
|
+
* @returns {Record<string, string>}
|
|
687
697
|
*/
|
|
688
698
|
declare function GetEventQuery(): ParameterDecorator;
|
|
689
699
|
|
|
@@ -719,19 +729,19 @@ declare function GetConnectionRequestId(): ParameterDecorator;
|
|
|
719
729
|
|
|
720
730
|
/**
|
|
721
731
|
* @desc The Decorator for retrieving the ConnectionParams in a handler
|
|
722
|
-
* @returns {
|
|
732
|
+
* @returns {Params}
|
|
723
733
|
*/
|
|
724
734
|
declare function GetConnectionParams(): ParameterDecorator;
|
|
725
735
|
|
|
726
736
|
/**
|
|
727
737
|
* @desc The Decorator for retrieving the ConnectionHeaders from the request in a handler
|
|
728
|
-
* @returns {
|
|
738
|
+
* @returns {IncomingHttpHeaders}
|
|
729
739
|
*/
|
|
730
740
|
declare function GetConnectionHeaders(): ParameterDecorator;
|
|
731
741
|
|
|
732
742
|
/**
|
|
733
743
|
* @desc The Decorator for retrieving the ConnectionQuery in a handler
|
|
734
|
-
* @returns {
|
|
744
|
+
* @returns {Record<string, string>}
|
|
735
745
|
*/
|
|
736
746
|
declare function GetConnectionQuery(): ParameterDecorator;
|
|
737
747
|
|