@eleven-am/pondsocket-nest 0.0.75 → 0.0.76
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/index.d.ts +8 -0
- package/modules/pondSocket.js +33 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ interface Metadata extends Omit<ModuleMetadata, 'controllers'> {
|
|
|
36
36
|
isGlobal?: boolean;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export interface AsyncMetadata extends Metadata {
|
|
40
|
+
inject?: any[];
|
|
41
|
+
imports?: any[];
|
|
42
|
+
useFactory: (...args: any[]) => Promise<RedisOptions>;
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
type NestFuncType<Event extends string, Payload extends PondMessage, Presence extends PondPresence, Assigns extends PondAssigns = PondAssigns> = {
|
|
40
46
|
event?: Event;
|
|
41
47
|
broadcast?: Event;
|
|
@@ -301,5 +307,7 @@ declare function createParamDecorator<Input, ParamType> (callback: ParamDecorato
|
|
|
301
307
|
|
|
302
308
|
declare class PondSocketModule {
|
|
303
309
|
static forRoot({ guards, providers, imports, exports, isGlobal, redisOptions }: Metadata): DynamicModule;
|
|
310
|
+
|
|
311
|
+
static forRootAsync({ guards, providers, imports, exports, isGlobal, useFactory, inject }: AsyncMetadata): Promise<DynamicModule>;
|
|
304
312
|
}
|
|
305
313
|
|
package/modules/pondSocket.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.PondSocketModule = void 0;
|
|
4
13
|
const nestjs_discovery_1 = require("@golevelup/nestjs-discovery");
|
|
@@ -11,7 +20,7 @@ class PondSocketModule {
|
|
|
11
20
|
const localGuards = (0, guards_1.getLocalGuards)();
|
|
12
21
|
const pondSocketProvider = {
|
|
13
22
|
provide: pondSocket_1.PondSocketService,
|
|
14
|
-
useFactory: (moduleRef, adapterHost, discovery) => new pondSocket_1.PondSocketService(moduleRef, discovery, adapterHost, guards),
|
|
23
|
+
useFactory: (moduleRef, adapterHost, discovery) => new pondSocket_1.PondSocketService(moduleRef, discovery, adapterHost, guards, redisOptions),
|
|
15
24
|
inject: [core_1.ModuleRef, core_1.HttpAdapterHost, nestjs_discovery_1.DiscoveryService],
|
|
16
25
|
};
|
|
17
26
|
guards = [...new Set([...localGuards, ...guards])];
|
|
@@ -27,5 +36,28 @@ class PondSocketModule {
|
|
|
27
36
|
],
|
|
28
37
|
};
|
|
29
38
|
}
|
|
39
|
+
static forRootAsync({ useFactory, inject = [], guards = [], imports = [], exports = [], providers = [], isGlobal = false, }) {
|
|
40
|
+
const localGuards = (0, guards_1.getLocalGuards)();
|
|
41
|
+
const pondSocketProvider = {
|
|
42
|
+
provide: pondSocket_1.PondSocketService,
|
|
43
|
+
inject: [core_1.ModuleRef, core_1.HttpAdapterHost, nestjs_discovery_1.DiscoveryService, ...inject],
|
|
44
|
+
useFactory: (moduleRef, adapterHost, discovery, ...args) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const redisOptions = yield useFactory(...args);
|
|
46
|
+
return new pondSocket_1.PondSocketService(moduleRef, discovery, adapterHost, guards, redisOptions);
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
guards = [...new Set([...localGuards, ...guards])];
|
|
50
|
+
return {
|
|
51
|
+
exports,
|
|
52
|
+
global: isGlobal,
|
|
53
|
+
imports: [...imports, nestjs_discovery_1.DiscoveryModule],
|
|
54
|
+
module: PondSocketModule,
|
|
55
|
+
providers: [
|
|
56
|
+
pondSocketProvider,
|
|
57
|
+
...providers,
|
|
58
|
+
...guards,
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
30
62
|
}
|
|
31
63
|
exports.PondSocketModule = PondSocketModule;
|