@common-stack/server-stack 7.0.4-alpha.17 → 7.0.4-alpha.18
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/lib/MainStackServer.cjs +231 -0
- package/lib/MainStackServer.cjs.map +1 -0
- package/lib/MainStackServer.d.ts +28 -0
- package/lib/MainStackServer.mjs +231 -0
- package/lib/MainStackServer.mjs.map +1 -0
- package/lib/StackServer.cjs +92 -0
- package/lib/StackServer.cjs.map +1 -0
- package/lib/StackServer.d.ts +20 -0
- package/lib/StackServer.mjs +92 -0
- package/lib/StackServer.mjs.map +1 -0
- package/lib/api/remote-config.cjs +6 -0
- package/lib/api/remote-config.cjs.map +1 -0
- package/lib/api/remote-config.d.ts +6 -0
- package/lib/api/remote-config.mjs +6 -0
- package/lib/api/remote-config.mjs.map +1 -0
- package/lib/api/resolver.cjs +12 -0
- package/lib/api/resolver.cjs.map +1 -0
- package/lib/api/resolver.d.ts +10 -0
- package/lib/api/resolver.mjs +12 -0
- package/lib/api/resolver.mjs.map +1 -0
- package/lib/api/root-schema.graphqls.cjs +2 -0
- package/lib/api/root-schema.graphqls.cjs.map +1 -0
- package/lib/api/root-schema.graphqls.mjs +2 -0
- package/lib/api/root-schema.graphqls.mjs.map +1 -0
- package/lib/api/scalar.cjs +16 -0
- package/lib/api/scalar.cjs.map +1 -0
- package/lib/api/scalar.d.ts +2 -0
- package/lib/api/scalar.mjs +16 -0
- package/lib/api/scalar.mjs.map +1 -0
- package/lib/api/schema-builder.cjs +160 -0
- package/lib/api/schema-builder.cjs.map +1 -0
- package/lib/api/schema-builder.d.ts +24 -0
- package/lib/api/schema-builder.mjs +160 -0
- package/lib/api/schema-builder.mjs.map +1 -0
- package/lib/api/utils.cjs +27 -0
- package/lib/api/utils.cjs.map +1 -0
- package/lib/api/utils.d.ts +4 -0
- package/lib/api/utils.mjs +27 -0
- package/lib/api/utils.mjs.map +1 -0
- package/lib/config/env-config.cjs +38 -0
- package/lib/config/env-config.cjs.map +1 -0
- package/lib/config/env-config.d.ts +21 -0
- package/lib/config/env-config.mjs +38 -0
- package/lib/config/env-config.mjs.map +1 -0
- package/lib/config/index.d.ts +1 -0
- package/lib/config/moleculer.config.cjs +191 -0
- package/lib/config/moleculer.config.cjs.map +1 -0
- package/lib/config/moleculer.config.d.ts +20 -0
- package/lib/config/moleculer.config.mjs +191 -0
- package/lib/config/moleculer.config.mjs.map +1 -0
- package/lib/connectors/connection-broker.cjs +61 -0
- package/lib/connectors/connection-broker.cjs.map +1 -0
- package/lib/connectors/connection-broker.d.ts +26 -0
- package/lib/connectors/connection-broker.mjs +61 -0
- package/lib/connectors/connection-broker.mjs.map +1 -0
- package/lib/connectors/graphql-pubsub-connector.cjs +28 -0
- package/lib/connectors/graphql-pubsub-connector.cjs.map +1 -0
- package/lib/connectors/graphql-pubsub-connector.d.ts +22 -0
- package/lib/connectors/graphql-pubsub-connector.mjs +28 -0
- package/lib/connectors/graphql-pubsub-connector.mjs.map +1 -0
- package/lib/connectors/mongo-connector.cjs +57 -0
- package/lib/connectors/mongo-connector.cjs.map +1 -0
- package/lib/connectors/mongo-connector.d.ts +21 -0
- package/lib/connectors/mongo-connector.mjs +57 -0
- package/lib/connectors/mongo-connector.mjs.map +1 -0
- package/lib/connectors/nats-connector.cjs +63 -0
- package/lib/connectors/nats-connector.cjs.map +1 -0
- package/lib/connectors/nats-connector.d.ts +20 -0
- package/lib/connectors/nats-connector.mjs +63 -0
- package/lib/connectors/nats-connector.mjs.map +1 -0
- package/lib/connectors/redis-connector.cjs +79 -0
- package/lib/connectors/redis-connector.cjs.map +1 -0
- package/lib/connectors/redis-connector.d.ts +30 -0
- package/lib/connectors/redis-connector.mjs +79 -0
- package/lib/connectors/redis-connector.mjs.map +1 -0
- package/lib/graphql/directives/index.cjs +10 -0
- package/lib/graphql/directives/index.cjs.map +1 -0
- package/lib/graphql/directives/index.d.ts +7 -0
- package/lib/graphql/directives/index.mjs +10 -0
- package/lib/graphql/directives/index.mjs.map +1 -0
- package/lib/graphql/index.d.ts +2 -0
- package/lib/graphql/schema/directives.graphql.cjs +1 -0
- package/lib/graphql/schema/directives.graphql.cjs.map +1 -0
- package/lib/graphql/schema/directives.graphql.mjs +1 -0
- package/lib/graphql/schema/directives.graphql.mjs.map +1 -0
- package/lib/graphql/schema/index.cjs +1 -0
- package/lib/graphql/schema/index.cjs.map +1 -0
- package/lib/graphql/schema/index.d.ts +1 -0
- package/lib/graphql/schema/index.mjs +1 -0
- package/lib/graphql/schema/index.mjs.map +1 -0
- package/lib/index.cjs +1 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.mjs +1 -0
- package/lib/index.mjs.map +1 -0
- package/lib/interfaces/dbMigration.d.ts +8 -0
- package/lib/interfaces/graphql-request-context.d.ts +15 -0
- package/lib/interfaces/index.d.ts +4 -0
- package/lib/interfaces/module-interface.d.ts +13 -0
- package/lib/interfaces/moleculer.d.ts +7 -0
- package/lib/middleware/cors.cjs +26 -0
- package/lib/middleware/cors.cjs.map +1 -0
- package/lib/middleware/cors.d.ts +6 -0
- package/lib/middleware/cors.mjs +26 -0
- package/lib/middleware/cors.mjs.map +1 -0
- package/lib/middleware/error.cjs +18 -0
- package/lib/middleware/error.cjs.map +1 -0
- package/lib/middleware/error.d.ts +9 -0
- package/lib/middleware/error.mjs +18 -0
- package/lib/middleware/error.mjs.map +1 -0
- package/lib/middleware/moleculer-inter-namespace.cjs +44 -0
- package/lib/middleware/moleculer-inter-namespace.cjs.map +1 -0
- package/lib/middleware/moleculer-inter-namespace.d.ts +2 -0
- package/lib/middleware/moleculer-inter-namespace.mjs +44 -0
- package/lib/middleware/moleculer-inter-namespace.mjs.map +1 -0
- package/lib/middleware/sentry.cjs +3 -0
- package/lib/middleware/sentry.cjs.map +1 -0
- package/lib/middleware/sentry.d.ts +2 -0
- package/lib/middleware/sentry.mjs +3 -0
- package/lib/middleware/sentry.mjs.map +1 -0
- package/lib/middleware/services.cjs +12 -0
- package/lib/middleware/services.cjs.map +1 -0
- package/lib/middleware/services.d.ts +2 -0
- package/lib/middleware/services.mjs +12 -0
- package/lib/middleware/services.mjs.map +1 -0
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/invalidateCachePlugin.cjs +63 -0
- package/lib/plugins/invalidateCachePlugin.cjs.map +1 -0
- package/lib/plugins/invalidateCachePlugin.d.ts +8 -0
- package/lib/plugins/invalidateCachePlugin.mjs +63 -0
- package/lib/plugins/invalidateCachePlugin.mjs.map +1 -0
- package/lib/plugins/invalidateCachePlugin.test.d.ts +1 -0
- package/lib/plugins/response-cache-plugin.test.d.ts +1 -0
- package/lib/plugins/responseCachePlugin.cjs +63 -0
- package/lib/plugins/responseCachePlugin.cjs.map +1 -0
- package/lib/plugins/responseCachePlugin.d.ts +12 -0
- package/lib/plugins/responseCachePlugin.mjs +63 -0
- package/lib/plugins/responseCachePlugin.mjs.map +1 -0
- package/lib/servers/ExpressApp.cjs +37 -0
- package/lib/servers/ExpressApp.cjs.map +1 -0
- package/lib/servers/ExpressApp.d.ts +3 -0
- package/lib/servers/ExpressApp.mjs +37 -0
- package/lib/servers/ExpressApp.mjs.map +1 -0
- package/lib/servers/GraphqlServer.cjs +142 -0
- package/lib/servers/GraphqlServer.cjs.map +1 -0
- package/lib/servers/GraphqlServer.d.ts +23 -0
- package/lib/servers/GraphqlServer.mjs +142 -0
- package/lib/servers/GraphqlServer.mjs.map +1 -0
- package/lib/servers/GraphqlWs.cjs +97 -0
- package/lib/servers/GraphqlWs.cjs.map +1 -0
- package/lib/servers/GraphqlWs.d.ts +14 -0
- package/lib/servers/GraphqlWs.mjs +97 -0
- package/lib/servers/GraphqlWs.mjs.map +1 -0
- package/lib/servers/WebsocketMultipathUpdate.cjs +63 -0
- package/lib/servers/WebsocketMultipathUpdate.cjs.map +1 -0
- package/lib/servers/WebsocketMultipathUpdate.d.ts +18 -0
- package/lib/servers/WebsocketMultipathUpdate.mjs +63 -0
- package/lib/servers/WebsocketMultipathUpdate.mjs.map +1 -0
- package/lib/servers/mongodb-migration-update.d.ts +12 -0
- package/lib/servers/utils.d.ts +14 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/migrations.cjs +26 -0
- package/lib/utils/migrations.cjs.map +1 -0
- package/lib/utils/migrations.d.ts +8 -0
- package/lib/utils/migrations.mjs +26 -0
- package/lib/utils/migrations.mjs.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';var mongoConnector=require('./mongo-connector.cjs'),natsConnector=require('./nats-connector.cjs'),redisConnector=require('./redis-connector.cjs'),envConfig=require('../config/env-config.cjs'),graphqlPubsubConnector=require('./graphql-pubsub-connector.cjs');/* eslint-disable no-underscore-dangle */
|
|
2
|
+
/**
|
|
3
|
+
* Connection broker class
|
|
4
|
+
*
|
|
5
|
+
* @class ConnectionBroker
|
|
6
|
+
*/
|
|
7
|
+
class ConnectionBroker {
|
|
8
|
+
_mongoConnector;
|
|
9
|
+
_redisConnector;
|
|
10
|
+
_natsConnector;
|
|
11
|
+
_graphqlPubsubConnector;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of ConnectionBroker.
|
|
14
|
+
* @param {*} options
|
|
15
|
+
* @memberof ConnectionBroker
|
|
16
|
+
*/
|
|
17
|
+
constructor(transporter, logger) {
|
|
18
|
+
if (typeof transporter === 'string') {
|
|
19
|
+
if (transporter === 'TCP') {
|
|
20
|
+
this._graphqlPubsubConnector = new graphqlPubsubConnector.GraphqlPubSubConnector({ logger, type: 'TCP' });
|
|
21
|
+
}
|
|
22
|
+
else if (transporter === 'NATS') {
|
|
23
|
+
this._natsConnector = new natsConnector.NatsConnector({});
|
|
24
|
+
this._graphqlPubsubConnector = new graphqlPubsubConnector.GraphqlPubSubConnector({
|
|
25
|
+
logger,
|
|
26
|
+
type: 'NATS',
|
|
27
|
+
client: this._natsConnector,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if (transporter && 'type' in transporter && transporter.type === 'NATS') {
|
|
32
|
+
// Ensure transporter.options is defined and properly typed if needed
|
|
33
|
+
this._natsConnector = new natsConnector.NatsConnector(transporter.options);
|
|
34
|
+
this._graphqlPubsubConnector = new graphqlPubsubConnector.GraphqlPubSubConnector({
|
|
35
|
+
logger,
|
|
36
|
+
type: 'NATS',
|
|
37
|
+
client: this._natsConnector,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// Ensure config.MONGO_URL is properly typed as string in your config
|
|
41
|
+
this._mongoConnector = new mongoConnector.MongoConnector(envConfig.config.MONGO_URL);
|
|
42
|
+
this._redisConnector = new redisConnector.RedisConnector(); // Pass constructor options if needed
|
|
43
|
+
}
|
|
44
|
+
get mongoConnection() {
|
|
45
|
+
return this._mongoConnector.connect();
|
|
46
|
+
}
|
|
47
|
+
get redisConnection() {
|
|
48
|
+
return this._redisConnector.connect();
|
|
49
|
+
}
|
|
50
|
+
get natsConnection() {
|
|
51
|
+
return this._natsConnector.connect();
|
|
52
|
+
}
|
|
53
|
+
get graphqlPubsub() {
|
|
54
|
+
return this._graphqlPubsubConnector.getClient();
|
|
55
|
+
}
|
|
56
|
+
async stop() {
|
|
57
|
+
this._mongoConnector && (await this._mongoConnector.disconnect());
|
|
58
|
+
this._redisConnector && (await this._redisConnector.disconnect());
|
|
59
|
+
this._natsConnector && (await this._natsConnector.disconnect());
|
|
60
|
+
}
|
|
61
|
+
}exports.ConnectionBroker=ConnectionBroker;//# sourceMappingURL=connection-broker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-broker.cjs","sources":["../../src/connectors/connection-broker.ts"],"sourcesContent":[null],"names":["GraphqlPubSubConnector","NatsConnector","MongoConnector","config","RedisConnector"],"mappings":"8QAAA;AAYA;;;;AAIG;MACU,gBAAgB,CAAA;AACjB,IAAA,eAAe,CAAiB;AAEhC,IAAA,eAAe,CAAiB;AAEhC,IAAA,cAAc,CAAgB;AAE9B,IAAA,u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AAC,OAAO,EAAE,CAAC;KACzC;AAED,IAAA,IAAW,cAAc,GAAA;AACrB,QAAA,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;KACxC;AAED,IAAA,IAAW,aAAa,GAAA;AACpB,QAAA,OAAO,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,CAAC;KACnD;AAEM,IAAA,MAAM,IAAI,GAAA;AACb,QAAA,IAAI,CAAC,eAAe,KAAK,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;AAClE,QAAA,IAAI,CAAC,eAAe,KAAK,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;AAClE,QAAA,IAAI,CAAC,cAAc,KAAK,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC;KACnE;AACJ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CdmLogger } from '@cdm-logger/core';
|
|
2
|
+
import { TransporterType } from '../interfaces/moleculer';
|
|
3
|
+
type ILogger = CdmLogger.ILogger;
|
|
4
|
+
/**
|
|
5
|
+
* Connection broker class
|
|
6
|
+
*
|
|
7
|
+
* @class ConnectionBroker
|
|
8
|
+
*/
|
|
9
|
+
export declare class ConnectionBroker {
|
|
10
|
+
private _mongoConnector;
|
|
11
|
+
private _redisConnector;
|
|
12
|
+
private _natsConnector;
|
|
13
|
+
private _graphqlPubsubConnector;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of ConnectionBroker.
|
|
16
|
+
* @param {*} options
|
|
17
|
+
* @memberof ConnectionBroker
|
|
18
|
+
*/
|
|
19
|
+
constructor(transporter: TransporterType, logger: ILogger);
|
|
20
|
+
get mongoConnection(): Promise<import("mongoose").Connection>;
|
|
21
|
+
get redisConnection(): Promise<import("ioredis").default | import("ioredis").Cluster>;
|
|
22
|
+
get natsConnection(): import("nats").Client | Promise<import("nats").Client>;
|
|
23
|
+
get graphqlPubsub(): Promise<import("graphql-nats-subscriptions").NatsPubSub | import("graphql-subscriptions").PubSub>;
|
|
24
|
+
stop(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {MongoConnector}from'./mongo-connector.mjs';import {NatsConnector}from'./nats-connector.mjs';import {RedisConnector}from'./redis-connector.mjs';import {config}from'../config/env-config.mjs';import {GraphqlPubSubConnector}from'./graphql-pubsub-connector.mjs';/* eslint-disable no-underscore-dangle */
|
|
2
|
+
/**
|
|
3
|
+
* Connection broker class
|
|
4
|
+
*
|
|
5
|
+
* @class ConnectionBroker
|
|
6
|
+
*/
|
|
7
|
+
class ConnectionBroker {
|
|
8
|
+
_mongoConnector;
|
|
9
|
+
_redisConnector;
|
|
10
|
+
_natsConnector;
|
|
11
|
+
_graphqlPubsubConnector;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of ConnectionBroker.
|
|
14
|
+
* @param {*} options
|
|
15
|
+
* @memberof ConnectionBroker
|
|
16
|
+
*/
|
|
17
|
+
constructor(transporter, logger) {
|
|
18
|
+
if (typeof transporter === 'string') {
|
|
19
|
+
if (transporter === 'TCP') {
|
|
20
|
+
this._graphqlPubsubConnector = new GraphqlPubSubConnector({ logger, type: 'TCP' });
|
|
21
|
+
}
|
|
22
|
+
else if (transporter === 'NATS') {
|
|
23
|
+
this._natsConnector = new NatsConnector({});
|
|
24
|
+
this._graphqlPubsubConnector = new GraphqlPubSubConnector({
|
|
25
|
+
logger,
|
|
26
|
+
type: 'NATS',
|
|
27
|
+
client: this._natsConnector,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if (transporter && 'type' in transporter && transporter.type === 'NATS') {
|
|
32
|
+
// Ensure transporter.options is defined and properly typed if needed
|
|
33
|
+
this._natsConnector = new NatsConnector(transporter.options);
|
|
34
|
+
this._graphqlPubsubConnector = new GraphqlPubSubConnector({
|
|
35
|
+
logger,
|
|
36
|
+
type: 'NATS',
|
|
37
|
+
client: this._natsConnector,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// Ensure config.MONGO_URL is properly typed as string in your config
|
|
41
|
+
this._mongoConnector = new MongoConnector(config.MONGO_URL);
|
|
42
|
+
this._redisConnector = new RedisConnector(); // Pass constructor options if needed
|
|
43
|
+
}
|
|
44
|
+
get mongoConnection() {
|
|
45
|
+
return this._mongoConnector.connect();
|
|
46
|
+
}
|
|
47
|
+
get redisConnection() {
|
|
48
|
+
return this._redisConnector.connect();
|
|
49
|
+
}
|
|
50
|
+
get natsConnection() {
|
|
51
|
+
return this._natsConnector.connect();
|
|
52
|
+
}
|
|
53
|
+
get graphqlPubsub() {
|
|
54
|
+
return this._graphqlPubsubConnector.getClient();
|
|
55
|
+
}
|
|
56
|
+
async stop() {
|
|
57
|
+
this._mongoConnector && (await this._mongoConnector.disconnect());
|
|
58
|
+
this._redisConnector && (await this._redisConnector.disconnect());
|
|
59
|
+
this._natsConnector && (await this._natsConnector.disconnect());
|
|
60
|
+
}
|
|
61
|
+
}export{ConnectionBroker};//# sourceMappingURL=connection-broker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-broker.mjs","sources":["../../src/connectors/connection-broker.ts"],"sourcesContent":[null],"names":[],"mappings":"yQAAA;AAYA;;;;AAIG;MACU,gBAAgB,CAAA;AACjB,IAAA,eAAe,CAAiB;AAEhC,IAAA,eAAe,CAAiB;AAEhC,IAAA,cAAc,CAAgB;AAE9B,IAAA,uBAAuB,CAAyB;AAExD;;;;AAIG;IACH,WAAY,CAAA,WAA4B,EAAE,MAAe,EAAA;AACrD,QAAA,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;AACjC,YAAA,IAAI,WAAW,KAAK,KAAK,EAAE;AACvB,gBAAA,IAAI,CAAC,uBAAuB,GAAG,IAAI,sBAAsB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;aACtF;AAAM,iBA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AAe,CAAC,UAAU,EAAE,CAAC,CAAC;AAClE,QAAA,IAAI,CAAC,eAAe,KAAK,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;AAClE,QAAA,IAAI,CAAC,cAAc,KAAK,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC;KACnE;AACJ"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';var graphqlSubscriptions=require('graphql-subscriptions'),graphqlNatsSubscriptions=require('graphql-nats-subscriptions'),server=require('@cdm-logger/server');class GraphqlPubSubConnector {
|
|
2
|
+
client;
|
|
3
|
+
opts;
|
|
4
|
+
logger;
|
|
5
|
+
/**
|
|
6
|
+
* Creates an instance of GraphqlPubSubConnector.
|
|
7
|
+
* @param {*} opts
|
|
8
|
+
* @memberof GraphqlPubSubConnector
|
|
9
|
+
*/
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
if (opts === undefined || opts.type === undefined) {
|
|
12
|
+
this.opts = { ...opts, apolloLogging: true, type: 'TCP' };
|
|
13
|
+
}
|
|
14
|
+
this.opts = opts;
|
|
15
|
+
this.logger = opts.logger.child({ className: 'GraphqlPubSubConnector' });
|
|
16
|
+
}
|
|
17
|
+
async getClient() {
|
|
18
|
+
if (this.opts.type === 'TCP') {
|
|
19
|
+
return (this.client = new graphqlSubscriptions.PubSub());
|
|
20
|
+
}
|
|
21
|
+
if (this.opts.type === 'NATS') {
|
|
22
|
+
const natsClient = await this.opts.client.connect();
|
|
23
|
+
return (this.client = new graphqlNatsSubscriptions.NatsPubSub({ client: natsClient, logger: server.logger }));
|
|
24
|
+
}
|
|
25
|
+
this.logger.warn('Did not defined known transporter [%s], return default pubsub', this.opts.type);
|
|
26
|
+
return (this.client = new graphqlSubscriptions.PubSub());
|
|
27
|
+
}
|
|
28
|
+
}exports.GraphqlPubSubConnector=GraphqlPubSubConnector;//# sourceMappingURL=graphql-pubsub-connector.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-pubsub-connector.cjs","sources":["../../src/connectors/graphql-pubsub-connector.ts"],"sourcesContent":[null],"names":["PubSub","NatsPubSub","logger"],"mappings":"iLAaa,sBAAsB,CAAA;AACvB,IAAA,MAAM,CAA4B;AAElC,IAAA,IAAI,CAAgB;AAEpB,IAAA,MAAM,CAAU;AAExB;;;;AAIG;AACH,IAAA,WAAA,CAAY,IAAoB,EAAA;QAC5B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;AAC/C,YAAA,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;SAC7D;AACD,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACjB,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC,CAAC;KAC5E;AAEM,IAAA,MAAM,SAAS,GAAA;QAClB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE;YAC1B,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAIA,2BAAM,EAAE,EAAE;SACvC;QACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;YAC3B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;AACpD,YAAA,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAIC,mCAAU,CAAC,EAAE,MAAM,EAAE,UAAU,UAAEC,aAAM,EAAE,CAAC,EAAE;SACzE;AACD,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+DAA+D,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClG,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAIF,2BAAM,EAAE,EAAE;KACvC;AACJ"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PubSub } from 'graphql-subscriptions';
|
|
2
|
+
import { NatsPubSub } from 'graphql-nats-subscriptions';
|
|
3
|
+
import { GenericObject } from 'moleculer';
|
|
4
|
+
import { CdmLogger } from '@cdm-logger/core';
|
|
5
|
+
type ILogger = CdmLogger.ILogger;
|
|
6
|
+
type PubSubOptions = {
|
|
7
|
+
apolloLogging?: boolean;
|
|
8
|
+
logger: ILogger;
|
|
9
|
+
} & GenericObject;
|
|
10
|
+
export declare class GraphqlPubSubConnector {
|
|
11
|
+
private client;
|
|
12
|
+
private opts;
|
|
13
|
+
private logger;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of GraphqlPubSubConnector.
|
|
16
|
+
* @param {*} opts
|
|
17
|
+
* @memberof GraphqlPubSubConnector
|
|
18
|
+
*/
|
|
19
|
+
constructor(opts?: PubSubOptions);
|
|
20
|
+
getClient(): Promise<NatsPubSub | PubSub>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {PubSub}from'graphql-subscriptions';import {NatsPubSub}from'graphql-nats-subscriptions';import {logger}from'@cdm-logger/server';class GraphqlPubSubConnector {
|
|
2
|
+
client;
|
|
3
|
+
opts;
|
|
4
|
+
logger;
|
|
5
|
+
/**
|
|
6
|
+
* Creates an instance of GraphqlPubSubConnector.
|
|
7
|
+
* @param {*} opts
|
|
8
|
+
* @memberof GraphqlPubSubConnector
|
|
9
|
+
*/
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
if (opts === undefined || opts.type === undefined) {
|
|
12
|
+
this.opts = { ...opts, apolloLogging: true, type: 'TCP' };
|
|
13
|
+
}
|
|
14
|
+
this.opts = opts;
|
|
15
|
+
this.logger = opts.logger.child({ className: 'GraphqlPubSubConnector' });
|
|
16
|
+
}
|
|
17
|
+
async getClient() {
|
|
18
|
+
if (this.opts.type === 'TCP') {
|
|
19
|
+
return (this.client = new PubSub());
|
|
20
|
+
}
|
|
21
|
+
if (this.opts.type === 'NATS') {
|
|
22
|
+
const natsClient = await this.opts.client.connect();
|
|
23
|
+
return (this.client = new NatsPubSub({ client: natsClient, logger }));
|
|
24
|
+
}
|
|
25
|
+
this.logger.warn('Did not defined known transporter [%s], return default pubsub', this.opts.type);
|
|
26
|
+
return (this.client = new PubSub());
|
|
27
|
+
}
|
|
28
|
+
}export{GraphqlPubSubConnector};//# sourceMappingURL=graphql-pubsub-connector.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-pubsub-connector.mjs","sources":["../../src/connectors/graphql-pubsub-connector.ts"],"sourcesContent":[null],"names":[],"mappings":"6IAaa,sBAAsB,CAAA;AACvB,IAAA,MAAM,CAA4B;AAElC,IAAA,IAAI,CAAgB;AAEpB,IAAA,MAAM,CAAU;AAExB;;;;AAIG;AACH,IAAA,WAAA,CAAY,IAAoB,EAAA;QAC5B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;AAC/C,YAAA,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;SAC7D;AACD,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACjB,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC,CAAC;KAC5E;AAEM,IAAA,MAAM,SAAS,GAAA;QAClB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE;YAC1B,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,EAAE,EAAE;SACvC;QACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;YAC3B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;AACpD,YAAA,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,EAAE;SACzE;AACD,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+DAA+D,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClG,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,EAAE,EAAE;KACvC;AACJ"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';var mongoose=require('mongoose'),_=require('lodash-es'),mongooseExecutionTime=require('mongoose-execution-time'),server=require('@cdm-logger/server'),envConfig=require('../config/env-config.cjs');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var ___namespace=/*#__PURE__*/_interopNamespaceDefault(_);class MongoConnector {
|
|
2
|
+
client;
|
|
3
|
+
db;
|
|
4
|
+
opts;
|
|
5
|
+
uri;
|
|
6
|
+
logger;
|
|
7
|
+
constructor(uri, opts) {
|
|
8
|
+
this.opts = ___namespace.defaultsDeep(opts, {});
|
|
9
|
+
this.uri = uri;
|
|
10
|
+
this.logger = server.logger.child({ className: 'MongoConnector' });
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Connect to database
|
|
14
|
+
*
|
|
15
|
+
* @memberof MongoConnector
|
|
16
|
+
*/
|
|
17
|
+
async connect() {
|
|
18
|
+
if (this.client) {
|
|
19
|
+
return this.client;
|
|
20
|
+
}
|
|
21
|
+
const conn = mongoose.createConnection(this.uri, this.opts).asPromise();
|
|
22
|
+
conn.then((result) => {
|
|
23
|
+
this.client = result;
|
|
24
|
+
this.db = result.db;
|
|
25
|
+
this.logger.info(' MongoDB has connected successfully.');
|
|
26
|
+
result.on('disconnected', () => this.logger.warn('Mongoose has disconnected.'));
|
|
27
|
+
result.on('error', (err) => this.logger.error(err, 'MongoDB error.'));
|
|
28
|
+
result.on('reconnect', () => this.logger.info('Mongoose has reconnected.'));
|
|
29
|
+
});
|
|
30
|
+
if (envConfig.config.NODE_ENV === 'development' ||
|
|
31
|
+
//__DEBUGGING__ ||
|
|
32
|
+
envConfig.config.LOG_LEVEL === 'debug' ||
|
|
33
|
+
envConfig.config.LOG_LEVEL === 'trace') {
|
|
34
|
+
mongoose.plugin(mongooseExecutionTime.logExecutionTime, {
|
|
35
|
+
logger: this.logger,
|
|
36
|
+
loggerVerbosity: mongooseExecutionTime.LoggerVerbosity.High,
|
|
37
|
+
loggerLevel: envConfig.config.LOG_LEVEL,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,global-require
|
|
41
|
+
// plugin(require('@kolinalabs/mongoose-consistent'), {
|
|
42
|
+
// actionDefault: 'no_action',
|
|
43
|
+
// });
|
|
44
|
+
return conn;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Disconnect from database
|
|
48
|
+
*
|
|
49
|
+
* @memberof MongoConnector
|
|
50
|
+
*/
|
|
51
|
+
async disconnect() {
|
|
52
|
+
if (!this.client) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
await mongoose.connection.close();
|
|
56
|
+
}
|
|
57
|
+
}exports.MongoConnector=MongoConnector;//# sourceMappingURL=mongo-connector.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo-connector.cjs","sources":["../../src/connectors/mongo-connector.ts"],"sourcesContent":[null],"names":["_","logger","createConnection","config","plugin","logExecutionTime","LoggerVerbosity","connection"],"mappings":"+iBAUa,cAAc,CAAA;AACf,IAAA,MAAM,CAAa;AAEnB,IAAA,EAAE,CAAK;AAEP,IAAA,IAAI,CAAiB;AAErB,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QAAQ,KAAK,aAAa;;YAEjCA,gBAAM,CAAC,SAAS,KAAK,OAAO;AAC5B,YAAAA,gBAAM,CAAC,SAAS,KAAK,OAAO,EAC9B;YACEC,eAAM,CAACC,sCAAgB,EAAE;gBACrB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,eAAe,EAAEC,qCAAe,CAAC,IAAI;gBACrC,WAAW,EAAEH,gBAAM,CAAC,SAAS;AAChC,aAAA,CAAC,CAAC;SACN;;;;;AAMD,QAAA,OAAO,IAAI,CAAC;KACf;AAED;;;;AAIG;AACI,IAAA,MAAM,UAAU,GAAA;AACnB,QAAA,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACd,OAAO;SACV;AACD,QAAA,MAAMI,mBAAU,CAAC,KAAK,EAAE,CAAC;KAC5B;AACJ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Connection, ConnectOptions } from 'mongoose';
|
|
2
|
+
export declare class MongoConnector {
|
|
3
|
+
private client;
|
|
4
|
+
private db;
|
|
5
|
+
private opts;
|
|
6
|
+
private uri;
|
|
7
|
+
private logger;
|
|
8
|
+
constructor(uri: string, opts?: ConnectOptions);
|
|
9
|
+
/**
|
|
10
|
+
* Connect to database
|
|
11
|
+
*
|
|
12
|
+
* @memberof MongoConnector
|
|
13
|
+
*/
|
|
14
|
+
connect(): Promise<Connection>;
|
|
15
|
+
/**
|
|
16
|
+
* Disconnect from database
|
|
17
|
+
*
|
|
18
|
+
* @memberof MongoConnector
|
|
19
|
+
*/
|
|
20
|
+
disconnect(): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {createConnection,plugin,connection}from'mongoose';import*as _ from'lodash-es';import {logExecutionTime,LoggerVerbosity}from'mongoose-execution-time';import {logger}from'@cdm-logger/server';import {config}from'../config/env-config.mjs';class MongoConnector {
|
|
2
|
+
client;
|
|
3
|
+
db;
|
|
4
|
+
opts;
|
|
5
|
+
uri;
|
|
6
|
+
logger;
|
|
7
|
+
constructor(uri, opts) {
|
|
8
|
+
this.opts = _.defaultsDeep(opts, {});
|
|
9
|
+
this.uri = uri;
|
|
10
|
+
this.logger = logger.child({ className: 'MongoConnector' });
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Connect to database
|
|
14
|
+
*
|
|
15
|
+
* @memberof MongoConnector
|
|
16
|
+
*/
|
|
17
|
+
async connect() {
|
|
18
|
+
if (this.client) {
|
|
19
|
+
return this.client;
|
|
20
|
+
}
|
|
21
|
+
const conn = createConnection(this.uri, this.opts).asPromise();
|
|
22
|
+
conn.then((result) => {
|
|
23
|
+
this.client = result;
|
|
24
|
+
this.db = result.db;
|
|
25
|
+
this.logger.info(' MongoDB has connected successfully.');
|
|
26
|
+
result.on('disconnected', () => this.logger.warn('Mongoose has disconnected.'));
|
|
27
|
+
result.on('error', (err) => this.logger.error(err, 'MongoDB error.'));
|
|
28
|
+
result.on('reconnect', () => this.logger.info('Mongoose has reconnected.'));
|
|
29
|
+
});
|
|
30
|
+
if (config.NODE_ENV === 'development' ||
|
|
31
|
+
//__DEBUGGING__ ||
|
|
32
|
+
config.LOG_LEVEL === 'debug' ||
|
|
33
|
+
config.LOG_LEVEL === 'trace') {
|
|
34
|
+
plugin(logExecutionTime, {
|
|
35
|
+
logger: this.logger,
|
|
36
|
+
loggerVerbosity: LoggerVerbosity.High,
|
|
37
|
+
loggerLevel: config.LOG_LEVEL,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,global-require
|
|
41
|
+
// plugin(require('@kolinalabs/mongoose-consistent'), {
|
|
42
|
+
// actionDefault: 'no_action',
|
|
43
|
+
// });
|
|
44
|
+
return conn;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Disconnect from database
|
|
48
|
+
*
|
|
49
|
+
* @memberof MongoConnector
|
|
50
|
+
*/
|
|
51
|
+
async disconnect() {
|
|
52
|
+
if (!this.client) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
await connection.close();
|
|
56
|
+
}
|
|
57
|
+
}export{MongoConnector};//# sourceMappingURL=mongo-connector.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo-connector.mjs","sources":["../../src/connectors/mongo-connector.ts"],"sourcesContent":[null],"names":[],"mappings":"yPAUa,cAAc,CAAA;AACf,IAAA,MAAM,CAAa;AAEnB,IAAA,EAAE,CAAK;AAEP,IAAA,IAAI,CAAiB;AAErB,IAAA,GAAG,CAAS;AAEZ,IAAA,MAAM,CAAU;IAExB,WAAY,CAAA,GAAW,EAAE,IAAqB,EAAA;QAC1C,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACrC,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;AACf,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC,CAAC;KAC/D;AAED;;;;AAIG;AACI,IAAA,MAAM,OAAO,GAAA;AAChB,QAAA,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,OAAO,IAAI,CAAC,MAAM,CAAC;SACtB;AACD,QAAA,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAE/D,QAAA,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;AACjB,YAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,YAAA,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;AACpB,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;AACzD,YAAA,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC;YAChF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC;AACtE,YAAA,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAC;AAChF,SAAC,CAAC,CAAC;AAEH,QAAA,IACI,MAAM,CAAC,QAAQ,KAAK,aAAa;;YAEjC,MAAM,CAAC,SAAS,KAAK,OAAO;AAC5B,YAAA,MAAM,CAAC,SAAS,KAAK,OAAO,EAC9B;YACE,MAAM,CAAC,gBAAgB,EAAE;gBACrB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,eAAe,EAAE,eAAe,CAAC,IAAI;gBACrC,WAAW,EAAE,MAAM,CAAC,SAAS;AAChC,aAAA,CAAC,CAAC;SACN;;;;;AAMD,QAAA,OAAO,IAAI,CAAC;KACf;AAED;;;;AAIG;AACI,IAAA,MAAM,UAAU,GAAA;AACnB,QAAA,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACd,OAAO;SACV;AACD,QAAA,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;KAC5B;AACJ"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';var nats=require('nats'),_=require('lodash-es'),server=require('@cdm-logger/server');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var nats__namespace=/*#__PURE__*/_interopNamespaceDefault(nats);var ___namespace=/*#__PURE__*/_interopNamespaceDefault(_);class NatsConnector {
|
|
2
|
+
opts;
|
|
3
|
+
client;
|
|
4
|
+
logger;
|
|
5
|
+
connected;
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
this.opts = ___namespace.defaultsDeep(opts, {});
|
|
8
|
+
this.logger = server.logger.child({ className: 'NatsConnector' });
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Connect to a NATS server
|
|
12
|
+
*
|
|
13
|
+
* @memberof NatsConnector
|
|
14
|
+
*/
|
|
15
|
+
connect() {
|
|
16
|
+
if (this.client) {
|
|
17
|
+
return this.client;
|
|
18
|
+
}
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const client = nats__namespace.connect(this.opts);
|
|
21
|
+
client.on('connect', () => {
|
|
22
|
+
this.client = client;
|
|
23
|
+
this.connected = true;
|
|
24
|
+
this.logger.info('NATS client is connected.');
|
|
25
|
+
resolve(client);
|
|
26
|
+
});
|
|
27
|
+
client.on('reconnect', () => {
|
|
28
|
+
this.logger.info('NATS client is reconnected.');
|
|
29
|
+
this.connected = true;
|
|
30
|
+
});
|
|
31
|
+
client.on('reconnecting', () => {
|
|
32
|
+
this.logger.warn('NATS client is reconnecting...');
|
|
33
|
+
});
|
|
34
|
+
client.on('disconnect', () => {
|
|
35
|
+
if (this.connected) {
|
|
36
|
+
this.logger.warn('NATS client is disconnected.');
|
|
37
|
+
this.connected = false;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
client.on('error', (e) => {
|
|
41
|
+
this.logger.error('NATS error.', e.message);
|
|
42
|
+
this.logger.debug(e);
|
|
43
|
+
reject(e);
|
|
44
|
+
});
|
|
45
|
+
client.on('close', () => {
|
|
46
|
+
this.logger.fatal('NATS connection close.');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Disconnect from a NATS server
|
|
52
|
+
*
|
|
53
|
+
* @memberof NatsTransporter
|
|
54
|
+
*/
|
|
55
|
+
disconnect() {
|
|
56
|
+
if (this.client) {
|
|
57
|
+
this.client.flush(() => {
|
|
58
|
+
this.client.close();
|
|
59
|
+
this.client = null;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}exports.NatsConnector=NatsConnector;//# sourceMappingURL=nats-connector.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nats-connector.cjs","sources":["../../src/connectors/nats-connector.ts"],"sourcesContent":[null],"names":["_","logger","nats"],"mappings":"ggBAOa,aAAa,CAAA;AACd,IAAA,IAAI,CAAkB;AAEtB,IAAA,MAAM,CAAc;AAEpB,IAAA,MAAM,CAAU;AAEhB,IAAA,SAAS,CAAU;AAE3B,IAAA,WAAA,CAAY,IAAqB,EAAA;QAC7B,IAAI,CAAC,IAAI,GAAGA,YAAC,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACrC,QAAA,IAAI,CAAC,MAAM,GAAGC,aAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;KAC9D;AAED;;;;AAIG;IACI,OAAO,GAAA;AACV,QAAA,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,OAAO,IAAI,CAAC,MAAM,CAAC;SACtB;QACD,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,KAAI;YAChD,MAAM,MAAM,GAAGC,eAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEvC,YAAA,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,MAAK;AACtB,gBAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,gBAAA,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AACtB,gBAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;gBAC9C,OAAO,CAAC,MAAM,CAAC,CAAC;AACpB,aAAC,CAAC,CAAC;AAEH,YAAA,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,MAAK;AACxB,gBAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CA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|
+
import * as nats from 'nats';
|
|
2
|
+
export declare class NatsConnector {
|
|
3
|
+
private opts;
|
|
4
|
+
private client;
|
|
5
|
+
private logger;
|
|
6
|
+
private connected;
|
|
7
|
+
constructor(opts: nats.ClientOpts);
|
|
8
|
+
/**
|
|
9
|
+
* Connect to a NATS server
|
|
10
|
+
*
|
|
11
|
+
* @memberof NatsConnector
|
|
12
|
+
*/
|
|
13
|
+
connect(): nats.Client | Promise<nats.Client>;
|
|
14
|
+
/**
|
|
15
|
+
* Disconnect from a NATS server
|
|
16
|
+
*
|
|
17
|
+
* @memberof NatsTransporter
|
|
18
|
+
*/
|
|
19
|
+
disconnect(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import*as nats from'nats';import*as _ from'lodash-es';import {logger}from'@cdm-logger/server';class NatsConnector {
|
|
2
|
+
opts;
|
|
3
|
+
client;
|
|
4
|
+
logger;
|
|
5
|
+
connected;
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
this.opts = _.defaultsDeep(opts, {});
|
|
8
|
+
this.logger = logger.child({ className: 'NatsConnector' });
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Connect to a NATS server
|
|
12
|
+
*
|
|
13
|
+
* @memberof NatsConnector
|
|
14
|
+
*/
|
|
15
|
+
connect() {
|
|
16
|
+
if (this.client) {
|
|
17
|
+
return this.client;
|
|
18
|
+
}
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const client = nats.connect(this.opts);
|
|
21
|
+
client.on('connect', () => {
|
|
22
|
+
this.client = client;
|
|
23
|
+
this.connected = true;
|
|
24
|
+
this.logger.info('NATS client is connected.');
|
|
25
|
+
resolve(client);
|
|
26
|
+
});
|
|
27
|
+
client.on('reconnect', () => {
|
|
28
|
+
this.logger.info('NATS client is reconnected.');
|
|
29
|
+
this.connected = true;
|
|
30
|
+
});
|
|
31
|
+
client.on('reconnecting', () => {
|
|
32
|
+
this.logger.warn('NATS client is reconnecting...');
|
|
33
|
+
});
|
|
34
|
+
client.on('disconnect', () => {
|
|
35
|
+
if (this.connected) {
|
|
36
|
+
this.logger.warn('NATS client is disconnected.');
|
|
37
|
+
this.connected = false;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
client.on('error', (e) => {
|
|
41
|
+
this.logger.error('NATS error.', e.message);
|
|
42
|
+
this.logger.debug(e);
|
|
43
|
+
reject(e);
|
|
44
|
+
});
|
|
45
|
+
client.on('close', () => {
|
|
46
|
+
this.logger.fatal('NATS connection close.');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Disconnect from a NATS server
|
|
52
|
+
*
|
|
53
|
+
* @memberof NatsTransporter
|
|
54
|
+
*/
|
|
55
|
+
disconnect() {
|
|
56
|
+
if (this.client) {
|
|
57
|
+
this.client.flush(() => {
|
|
58
|
+
this.client.close();
|
|
59
|
+
this.client = null;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}export{NatsConnector};//# sourceMappingURL=nats-connector.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nats-connector.mjs","sources":["../../src/connectors/nats-connector.ts"],"sourcesContent":[null],"names":[],"mappings":"oGAOa,aAAa,CAAA;AACd,IAAA,IAAI,CAAkB;AAEtB,IAAA,MAAM,CAAc;AAEpB,IAAA,MAAM,CAAU;AAEhB,IAAA,SAAS,CAAU;AAE3B,IAAA,WAAA,CAAY,IAAqB,EAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACrC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;KAC9D;AAED;;;;AAIG;IACI,OAAO,GAAA;AACV,QAAA,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,OAAO,IAA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AK,CAAC,CAAC,CAAC,CAAC;gBACrB,MAAM,CAAC,CAAC,CAAC,CAAC;AACd,aAAC,CAAC,CAAC;AAEH,YAAA,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAK;AACpB,gBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAChD,aAAC,CAAC,CAAC;AACP,SAAC,CAAC,CAAC;KACN;AAED;;;;AAIG;IACI,UAAU,GAAA;AACb,QAAA,IAAI,IAAI,CAAC,MAAM,EAAE;AACb,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAK;AACnB,gBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;AACpB,gBAAA,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;AACvB,aAAC,CAAC,CAAC;SACN;KACJ;AACJ"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';var _=require('lodash-es'),IORedis=require('ioredis'),server=require('@cdm-logger/server'),envConfig=require('../config/env-config.cjs');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var ___namespace=/*#__PURE__*/_interopNamespaceDefault(_);var IORedis__namespace=/*#__PURE__*/_interopNamespaceDefault(IORedis);class RedisConnector {
|
|
2
|
+
client;
|
|
3
|
+
opts;
|
|
4
|
+
logger;
|
|
5
|
+
/**
|
|
6
|
+
* Creates an instance of RedisConnector.
|
|
7
|
+
*
|
|
8
|
+
* @param {object} opts
|
|
9
|
+
*/
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
this.opts = ___namespace.defaultsDeep(opts, {
|
|
12
|
+
prefix: null,
|
|
13
|
+
});
|
|
14
|
+
this.logger = server.logger.child({ className: 'RedisConnector' });
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Connect to the Redis server
|
|
18
|
+
*
|
|
19
|
+
* @memberof RedisConnector
|
|
20
|
+
*/
|
|
21
|
+
async connect() {
|
|
22
|
+
if (this.client) {
|
|
23
|
+
return this.client;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
this.logger.info('Attempting to connect to Redis...');
|
|
27
|
+
this.client = this.getRedisClient();
|
|
28
|
+
// Test the connection by pinging the Redis server
|
|
29
|
+
await this.client.ping();
|
|
30
|
+
this.logger.info('Successfully connected to Redis.');
|
|
31
|
+
this.client.on('error', (err) => this.logger.error(err, 'Redis error:'));
|
|
32
|
+
this.client.on('end', () => this.logger.warn('Redis connection closed.'));
|
|
33
|
+
this.client.on('reconnecting', () => this.logger.info('Reconnecting to Redis...'));
|
|
34
|
+
return this.client;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
this.logger.error('Failed to connect to Redis:', error);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Return redis or redis.cluster Client
|
|
43
|
+
*
|
|
44
|
+
* @memberof RedisConnection
|
|
45
|
+
*/
|
|
46
|
+
getRedisClient() {
|
|
47
|
+
let client;
|
|
48
|
+
if (envConfig.config.REDIS_CLUSTER_ENABLED) {
|
|
49
|
+
if (!envConfig.config.REDIS_CLUSTER_URL) {
|
|
50
|
+
throw new Error(`No nodes defined for cluster, ${envConfig.config.REDIS_CLUSTER_URL}`);
|
|
51
|
+
}
|
|
52
|
+
this.logger.info('Setting Redis.Cluster connection');
|
|
53
|
+
client = new IORedis__namespace.Cluster(envConfig.config.REDIS_CLUSTER_URL, this.opts);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.logger.info('Setting Redis connection');
|
|
57
|
+
if (typeof envConfig.config.REDIS_URL === 'string') {
|
|
58
|
+
client = new IORedis__namespace.Redis(envConfig.config.REDIS_URL, this.opts);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
client = new IORedis__namespace.Redis(this.opts);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
this.client = client;
|
|
65
|
+
return client;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Close Redis client connection.
|
|
69
|
+
*
|
|
70
|
+
* @memberof RedisConnection
|
|
71
|
+
*/
|
|
72
|
+
async disconnect() {
|
|
73
|
+
if (!this.client) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
await this.client.quit();
|
|
77
|
+
this.logger.info('Redis connection closed.');
|
|
78
|
+
}
|
|
79
|
+
}exports.RedisConnector=RedisConnector;//# sourceMappingURL=redis-connector.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-connector.cjs","sources":["../../src/connectors/redis-connector.ts"],"sourcesContent":[null],"names":["_","logger","config","IORedis"],"mappings":"0jBAQa,cAAc,CAAA;AACf,IAAA,MAAM,CAAkC;AAExC,IAAA,IAAI,CAAgD;AAEpD,IAAA,MAAM,CAAU;AAExB;;;;AAIG;AACH,IAAA,WAAA,CAAY,IAAoD,EAAA;QAC5D,IAAI,CAAC,IAAI,GAAGA,YAAC,CAAC,YAAY,CAAC,IAAI,EAAE;AAC7B,YAAA,MAAM,EAAE,IAAI;AACf,SAAA,CAAC,CAAC;AACH,QAAA,IAAI,CAAC,MAAM,GAAGC,aAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC,CAAC;KAC/D;AAED;;;;AAIG;AACI,IAAA,MAAM,OAAO,GAAA;AAChB,QAAA,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,OAAO,IAAI,CAAC,MAAM,CAAC;SACtB;AAED,QAAA,IAAI;AACA,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;AACtD,YAAA,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;;AAGpC,YAAA,MAAM,IAAI,CA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