@common-stack/server-stack 7.0.4-alpha.15 → 7.0.4-alpha.17
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/package.json +7 -7
- package/lib/MainStackServer.cjs +0 -231
- package/lib/MainStackServer.cjs.map +0 -1
- package/lib/MainStackServer.d.ts +0 -28
- package/lib/MainStackServer.mjs +0 -231
- package/lib/MainStackServer.mjs.map +0 -1
- package/lib/StackServer.cjs +0 -92
- package/lib/StackServer.cjs.map +0 -1
- package/lib/StackServer.d.ts +0 -20
- package/lib/StackServer.mjs +0 -92
- package/lib/StackServer.mjs.map +0 -1
- package/lib/api/remote-config.cjs +0 -6
- package/lib/api/remote-config.cjs.map +0 -1
- package/lib/api/remote-config.d.ts +0 -6
- package/lib/api/remote-config.mjs +0 -6
- package/lib/api/remote-config.mjs.map +0 -1
- package/lib/api/resolver.cjs +0 -12
- package/lib/api/resolver.cjs.map +0 -1
- package/lib/api/resolver.d.ts +0 -10
- package/lib/api/resolver.mjs +0 -12
- package/lib/api/resolver.mjs.map +0 -1
- package/lib/api/root-schema.graphqls.cjs +0 -2
- package/lib/api/root-schema.graphqls.cjs.map +0 -1
- package/lib/api/root-schema.graphqls.mjs +0 -2
- package/lib/api/root-schema.graphqls.mjs.map +0 -1
- package/lib/api/scalar.cjs +0 -16
- package/lib/api/scalar.cjs.map +0 -1
- package/lib/api/scalar.d.ts +0 -2
- package/lib/api/scalar.mjs +0 -16
- package/lib/api/scalar.mjs.map +0 -1
- package/lib/api/schema-builder.cjs +0 -160
- package/lib/api/schema-builder.cjs.map +0 -1
- package/lib/api/schema-builder.d.ts +0 -24
- package/lib/api/schema-builder.mjs +0 -160
- package/lib/api/schema-builder.mjs.map +0 -1
- package/lib/api/utils.cjs +0 -27
- package/lib/api/utils.cjs.map +0 -1
- package/lib/api/utils.d.ts +0 -4
- package/lib/api/utils.mjs +0 -27
- package/lib/api/utils.mjs.map +0 -1
- package/lib/config/env-config.cjs +0 -38
- package/lib/config/env-config.cjs.map +0 -1
- package/lib/config/env-config.d.ts +0 -21
- package/lib/config/env-config.mjs +0 -38
- package/lib/config/env-config.mjs.map +0 -1
- package/lib/config/index.d.ts +0 -1
- package/lib/config/moleculer.config.cjs +0 -191
- package/lib/config/moleculer.config.cjs.map +0 -1
- package/lib/config/moleculer.config.d.ts +0 -20
- package/lib/config/moleculer.config.mjs +0 -191
- package/lib/config/moleculer.config.mjs.map +0 -1
- package/lib/connectors/connection-broker.cjs +0 -61
- package/lib/connectors/connection-broker.cjs.map +0 -1
- package/lib/connectors/connection-broker.d.ts +0 -26
- package/lib/connectors/connection-broker.mjs +0 -61
- package/lib/connectors/connection-broker.mjs.map +0 -1
- package/lib/connectors/graphql-pubsub-connector.cjs +0 -28
- package/lib/connectors/graphql-pubsub-connector.cjs.map +0 -1
- package/lib/connectors/graphql-pubsub-connector.d.ts +0 -22
- package/lib/connectors/graphql-pubsub-connector.mjs +0 -28
- package/lib/connectors/graphql-pubsub-connector.mjs.map +0 -1
- package/lib/connectors/mongo-connector.cjs +0 -57
- package/lib/connectors/mongo-connector.cjs.map +0 -1
- package/lib/connectors/mongo-connector.d.ts +0 -21
- package/lib/connectors/mongo-connector.mjs +0 -57
- package/lib/connectors/mongo-connector.mjs.map +0 -1
- package/lib/connectors/nats-connector.cjs +0 -63
- package/lib/connectors/nats-connector.cjs.map +0 -1
- package/lib/connectors/nats-connector.d.ts +0 -20
- package/lib/connectors/nats-connector.mjs +0 -63
- package/lib/connectors/nats-connector.mjs.map +0 -1
- package/lib/connectors/redis-connector.cjs +0 -79
- package/lib/connectors/redis-connector.cjs.map +0 -1
- package/lib/connectors/redis-connector.d.ts +0 -30
- package/lib/connectors/redis-connector.mjs +0 -79
- package/lib/connectors/redis-connector.mjs.map +0 -1
- package/lib/graphql/directives/index.cjs +0 -10
- package/lib/graphql/directives/index.cjs.map +0 -1
- package/lib/graphql/directives/index.d.ts +0 -7
- package/lib/graphql/directives/index.mjs +0 -10
- package/lib/graphql/directives/index.mjs.map +0 -1
- package/lib/graphql/index.d.ts +0 -2
- package/lib/graphql/schema/directives.graphql.cjs +0 -1
- package/lib/graphql/schema/directives.graphql.cjs.map +0 -1
- package/lib/graphql/schema/directives.graphql.mjs +0 -1
- package/lib/graphql/schema/directives.graphql.mjs.map +0 -1
- package/lib/graphql/schema/index.cjs +0 -1
- package/lib/graphql/schema/index.cjs.map +0 -1
- package/lib/graphql/schema/index.d.ts +0 -1
- package/lib/graphql/schema/index.mjs +0 -1
- package/lib/graphql/schema/index.mjs.map +0 -1
- package/lib/index.cjs +0 -1
- package/lib/index.cjs.map +0 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.mjs +0 -1
- package/lib/index.mjs.map +0 -1
- package/lib/interfaces/dbMigration.d.ts +0 -8
- package/lib/interfaces/graphql-request-context.d.ts +0 -15
- package/lib/interfaces/index.d.ts +0 -4
- package/lib/interfaces/module-interface.d.ts +0 -13
- package/lib/interfaces/moleculer.d.ts +0 -7
- package/lib/middleware/cors.cjs +0 -26
- package/lib/middleware/cors.cjs.map +0 -1
- package/lib/middleware/cors.d.ts +0 -6
- package/lib/middleware/cors.mjs +0 -26
- package/lib/middleware/cors.mjs.map +0 -1
- package/lib/middleware/error.cjs +0 -18
- package/lib/middleware/error.cjs.map +0 -1
- package/lib/middleware/error.d.ts +0 -9
- package/lib/middleware/error.mjs +0 -18
- package/lib/middleware/error.mjs.map +0 -1
- package/lib/middleware/moleculer-inter-namespace.cjs +0 -44
- package/lib/middleware/moleculer-inter-namespace.cjs.map +0 -1
- package/lib/middleware/moleculer-inter-namespace.d.ts +0 -2
- package/lib/middleware/moleculer-inter-namespace.mjs +0 -44
- package/lib/middleware/moleculer-inter-namespace.mjs.map +0 -1
- package/lib/middleware/sentry.cjs +0 -3
- package/lib/middleware/sentry.cjs.map +0 -1
- package/lib/middleware/sentry.d.ts +0 -2
- package/lib/middleware/sentry.mjs +0 -3
- package/lib/middleware/sentry.mjs.map +0 -1
- package/lib/middleware/services.cjs +0 -12
- package/lib/middleware/services.cjs.map +0 -1
- package/lib/middleware/services.d.ts +0 -2
- package/lib/middleware/services.mjs +0 -12
- package/lib/middleware/services.mjs.map +0 -1
- package/lib/plugins/index.d.ts +0 -2
- package/lib/plugins/invalidateCachePlugin.cjs +0 -59
- package/lib/plugins/invalidateCachePlugin.cjs.map +0 -1
- package/lib/plugins/invalidateCachePlugin.d.ts +0 -8
- package/lib/plugins/invalidateCachePlugin.mjs +0 -59
- package/lib/plugins/invalidateCachePlugin.mjs.map +0 -1
- package/lib/plugins/responseCachePlugin.cjs +0 -58
- package/lib/plugins/responseCachePlugin.cjs.map +0 -1
- package/lib/plugins/responseCachePlugin.d.ts +0 -8
- package/lib/plugins/responseCachePlugin.mjs +0 -58
- package/lib/plugins/responseCachePlugin.mjs.map +0 -1
- package/lib/servers/ExpressApp.cjs +0 -37
- package/lib/servers/ExpressApp.cjs.map +0 -1
- package/lib/servers/ExpressApp.d.ts +0 -3
- package/lib/servers/ExpressApp.mjs +0 -37
- package/lib/servers/ExpressApp.mjs.map +0 -1
- package/lib/servers/GraphqlServer.cjs +0 -142
- package/lib/servers/GraphqlServer.cjs.map +0 -1
- package/lib/servers/GraphqlServer.d.ts +0 -23
- package/lib/servers/GraphqlServer.mjs +0 -142
- package/lib/servers/GraphqlServer.mjs.map +0 -1
- package/lib/servers/GraphqlWs.cjs +0 -97
- package/lib/servers/GraphqlWs.cjs.map +0 -1
- package/lib/servers/GraphqlWs.d.ts +0 -14
- package/lib/servers/GraphqlWs.mjs +0 -97
- package/lib/servers/GraphqlWs.mjs.map +0 -1
- package/lib/servers/WebsocketMultipathUpdate.cjs +0 -63
- package/lib/servers/WebsocketMultipathUpdate.cjs.map +0 -1
- package/lib/servers/WebsocketMultipathUpdate.d.ts +0 -18
- package/lib/servers/WebsocketMultipathUpdate.mjs +0 -63
- package/lib/servers/WebsocketMultipathUpdate.mjs.map +0 -1
- package/lib/servers/mongodb-migration-update.d.ts +0 -12
- package/lib/servers/utils.d.ts +0 -14
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/migrations.cjs +0 -26
- package/lib/utils/migrations.cjs.map +0 -1
- package/lib/utils/migrations.d.ts +0 -8
- package/lib/utils/migrations.mjs +0 -26
- package/lib/utils/migrations.mjs.map +0 -1
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import {config}from'./env-config.mjs';/**
|
|
2
|
-
* Moleculer ServiceBroker configuration file
|
|
3
|
-
*
|
|
4
|
-
* More info about options:
|
|
5
|
-
* https://moleculer.services/docs/0.14/configuration.html
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Overwrite options in production:
|
|
9
|
-
* ================================
|
|
10
|
-
* You can overwrite any option with environment variables.
|
|
11
|
-
* For example to overwrite the 'logLevel', use `LOGLEVEL=warn` env var.
|
|
12
|
-
* To overwrite a nested parameter, e.g. retryPolicy.retries, use `RETRYPOLICY_RETRIES=10` env var.
|
|
13
|
-
*
|
|
14
|
-
* To overwrite broker’s deeply nested default options, which are not presented in 'moleculer.config.ts',
|
|
15
|
-
* via environment variables, use the `MOL_` prefix and double underscore `__` for nested properties in .env file.
|
|
16
|
-
* For example, to set the cacher prefix to `MYCACHE`, you should declare an env var as `MOL_CACHER__OPTIONS__PREFIX=MYCACHE`.
|
|
17
|
-
*/
|
|
18
|
-
const brokerConfig = {
|
|
19
|
-
// Namespace of nodes to segment your nodes on the same network.
|
|
20
|
-
namespace: config.NAMESPACE,
|
|
21
|
-
// namespace: null,
|
|
22
|
-
// Unique node identifier. Must be unique in a namespace.
|
|
23
|
-
// nodeID: config.CONNECTION_ID,
|
|
24
|
-
// Enable/disable logging or use custom logger. More info: https://moleculer.services/docs/0.14/logging.html
|
|
25
|
-
// Available logger types: 'Console', 'File', 'Pino', 'Winston', 'Bunyan', 'debug', 'Log4js', 'Datadog'
|
|
26
|
-
logger: {
|
|
27
|
-
type: 'Console',
|
|
28
|
-
options: {
|
|
29
|
-
// Using colors on the output
|
|
30
|
-
colors: true,
|
|
31
|
-
// Print module names with different colors (like docker-compose for containers)
|
|
32
|
-
moduleColors: false,
|
|
33
|
-
// Line formatter. It can be 'json', 'short',
|
|
34
|
-
// 'simple', 'full', a `Function` or a template string like '{timestamp} {level} {nodeID}/{mod}: {msg}'
|
|
35
|
-
formatter: 'full',
|
|
36
|
-
// Custom object printer. If not defined, it uses the `util.inspect` method.
|
|
37
|
-
objectPrinter: null,
|
|
38
|
-
// Auto-padding the module name in order to messages begin at the same column.
|
|
39
|
-
autoPadding: false,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
// Default log level for built-in console logger. It can be overwritten in logger options above.
|
|
43
|
-
// Available values: trace, debug, info, warn, error, fatal
|
|
44
|
-
logLevel: config.LOG_LEVEL,
|
|
45
|
-
// Define transporter.
|
|
46
|
-
// More info: https://moleculer.services/docs/0.14/networking.html
|
|
47
|
-
// Note: During the development, you don't need to define it because all services will be loaded locally.
|
|
48
|
-
// In production you can set it via `TRANSPORTER=nats://localhost:4222` environment variable.
|
|
49
|
-
transporter: config.NODE_ENV === 'development'
|
|
50
|
-
? 'TCP'
|
|
51
|
-
: {
|
|
52
|
-
type: 'NATS',
|
|
53
|
-
options: {
|
|
54
|
-
url: config.NATS_URL,
|
|
55
|
-
user: config.NATS_USER,
|
|
56
|
-
pass: config.NATS_PW,
|
|
57
|
-
reconnectTimeWait: 1000,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
// Define a cacher.
|
|
61
|
-
// More info: https://moleculer.services/docs/0.14/caching.html
|
|
62
|
-
// cacher: {
|
|
63
|
-
// type: 'Redis',
|
|
64
|
-
// enabled: false,
|
|
65
|
-
// options: {
|
|
66
|
-
// // Redis settings
|
|
67
|
-
// redis: {
|
|
68
|
-
// }
|
|
69
|
-
// }
|
|
70
|
-
// },
|
|
71
|
-
// Define a serializer.
|
|
72
|
-
// Available values: 'JSON', 'Avro', 'ProtoBuf', 'MsgPack', 'Notepack', 'Thrift'.
|
|
73
|
-
// More info: https://moleculer.services/docs/0.13/networking.html
|
|
74
|
-
serializer: 'JSON',
|
|
75
|
-
// Number of milliseconds to wait before reject a request with a RequestTimeout error. Disabled: 0
|
|
76
|
-
requestTimeout: 10 * 1000,
|
|
77
|
-
// Retry policy settings. More info: https://moleculer.services/docs/0.13/fault-tolerance.html#Retry
|
|
78
|
-
retryPolicy: {
|
|
79
|
-
// Enable feature
|
|
80
|
-
enabled: false,
|
|
81
|
-
// Count of retries
|
|
82
|
-
retries: 5,
|
|
83
|
-
// First delay in milliseconds.
|
|
84
|
-
delay: 100,
|
|
85
|
-
// Maximum delay in milliseconds.
|
|
86
|
-
maxDelay: 1000,
|
|
87
|
-
// Backoff factor for delay. 2 means exponential backoff.
|
|
88
|
-
factor: 2,
|
|
89
|
-
// A function to check failed requests.
|
|
90
|
-
check: (err) => err && !!err.retryable,
|
|
91
|
-
},
|
|
92
|
-
// Limit of calling level. If it reaches the limit, broker will throw an MaxCallLevelError error. (Infinite loop protection)
|
|
93
|
-
maxCallLevel: 100,
|
|
94
|
-
// Number of seconds to send heartbeat packet to other nodes.
|
|
95
|
-
heartbeatInterval: 5,
|
|
96
|
-
// Number of seconds to wait before setting node to unavailable status.
|
|
97
|
-
heartbeatTimeout: 15,
|
|
98
|
-
// tslint:disable-next-line:max-line-length
|
|
99
|
-
// Tracking requests and waiting for running requests before shutdowning. More info: https://moleculer.services/docs/0.13/fault-tolerance.html
|
|
100
|
-
tracking: {
|
|
101
|
-
// Enable feature
|
|
102
|
-
enabled: false,
|
|
103
|
-
// Number of milliseconds to wait before shutdowning the process
|
|
104
|
-
shutdownTimeout: 5000,
|
|
105
|
-
},
|
|
106
|
-
// Disable built-in request & emit balancer. (Transporter must support it, as well.)
|
|
107
|
-
disableBalancer: false,
|
|
108
|
-
// Settings of Service Registry. More info: https://moleculer.services/docs/0.14/registry.html
|
|
109
|
-
registry: {
|
|
110
|
-
// Define balancing strategy. More info: https://moleculer.services/docs/0.14/balancing.html
|
|
111
|
-
// Available values: 'RoundRobin', 'Random', 'CpuUsage', 'Latency'
|
|
112
|
-
strategy: 'RoundRobin',
|
|
113
|
-
// Enable local action call preferring.
|
|
114
|
-
preferLocal: true,
|
|
115
|
-
},
|
|
116
|
-
// Settings of Circuit Breaker. More info: https://moleculer.services/docs/0.14/fault-tolerance.html#Circuit-Breaker
|
|
117
|
-
circuitBreaker: {
|
|
118
|
-
// Enable feature
|
|
119
|
-
enabled: false,
|
|
120
|
-
// Threshold value. 0.5 means that 50% should be failed for tripping.
|
|
121
|
-
threshold: 0.5,
|
|
122
|
-
// Minimum request count. Below it, CB does not trip.
|
|
123
|
-
minRequestCount: 20,
|
|
124
|
-
// Number of seconds for time window.
|
|
125
|
-
windowTime: 60,
|
|
126
|
-
// Number of milliseconds to switch from open to half-open state
|
|
127
|
-
halfOpenTime: 10 * 1000,
|
|
128
|
-
// A function to check failed requests.
|
|
129
|
-
check: (err) => err && err.code >= 500,
|
|
130
|
-
},
|
|
131
|
-
// Settings of bulkhead feature. More info: https://moleculer.services/docs/0.14/fault-tolerance.html#Bulkhead
|
|
132
|
-
bulkhead: {
|
|
133
|
-
// Enable feature.
|
|
134
|
-
enabled: false,
|
|
135
|
-
// Maximum concurrent executions.
|
|
136
|
-
concurrency: 10,
|
|
137
|
-
// Maximum size of queue
|
|
138
|
-
maxQueueSize: 100,
|
|
139
|
-
},
|
|
140
|
-
// Enable action & event parameter validation. More info: https://moleculer.services/docs/0.14/validating.html
|
|
141
|
-
validator: true,
|
|
142
|
-
errorHandler: null,
|
|
143
|
-
// Enable/disable built-in metrics function. More info: https://moleculer.services/docs/0.14/metrics.html
|
|
144
|
-
metrics: {
|
|
145
|
-
enabled: config.METRICS_CONFIG.enabled,
|
|
146
|
-
reporter: {
|
|
147
|
-
type: 'Prometheus',
|
|
148
|
-
options: {
|
|
149
|
-
port: config.METRICS_CONFIG.port,
|
|
150
|
-
path: config.METRICS_CONFIG.path,
|
|
151
|
-
defaultLabels: (registry) => ({
|
|
152
|
-
namespace: registry.broker.namespace,
|
|
153
|
-
nodeID: registry.broker.nodeID,
|
|
154
|
-
}),
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
// Enable built-in tracing function. More info: https://moleculer.services/docs/0.14/tracing.html
|
|
159
|
-
tracing: {
|
|
160
|
-
enabled: true,
|
|
161
|
-
// Available built-in exporters: 'Console', 'Datadog', 'Event', 'EventLegacy', 'Jaeger', 'Zipkin'
|
|
162
|
-
exporter: {
|
|
163
|
-
type: 'Console', // Console exporter is only for development!
|
|
164
|
-
options: {
|
|
165
|
-
// Custom logger
|
|
166
|
-
logger: null,
|
|
167
|
-
// Using colors
|
|
168
|
-
colors: true,
|
|
169
|
-
// Width of row
|
|
170
|
-
width: 100,
|
|
171
|
-
// Gauge width in the row
|
|
172
|
-
gaugeWidth: 40,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
// Register internal services ('$node'). More info: https://moleculer.services/docs/0.13/services.html#Internal-services
|
|
177
|
-
internalServices: true,
|
|
178
|
-
// Register internal middlewares. More info: https://moleculer.services/docs/0.13/middlewares.html#Internal-middlewares
|
|
179
|
-
internalMiddlewares: true,
|
|
180
|
-
// Watch the loaded services and hot reload if they changed.
|
|
181
|
-
// You can also enable it in Moleculer Runner with `--hot` argument
|
|
182
|
-
hotReload: false,
|
|
183
|
-
// Register custom middlewares
|
|
184
|
-
middlewares: [],
|
|
185
|
-
// Called after broker created.
|
|
186
|
-
created(broker) { },
|
|
187
|
-
// Called after broker starte.
|
|
188
|
-
started(broker) { },
|
|
189
|
-
// Called after broker stopped.
|
|
190
|
-
stopped(broker) { },
|
|
191
|
-
};export{brokerConfig as default};//# sourceMappingURL=moleculer.config.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"moleculer.config.mjs","sources":["../../src/config/moleculer.config.ts"],"sourcesContent":[null],"names":[],"mappings":"sCAIA;;;;;;;;;;;;;;;;AAgBG;AACH,MAAM,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OAAO,EAAE;;AAEL,gBAAA,MAAM,EAAE,IAAI;;AAEZ,gBAAA,MAAM,EAAE,IAAI;;AAEZ,gBAAA,KAAK,EAAE,GAAG;;AAEV,gBAAA,UAAU,EAAE,EAAE;AACjB,aAAA;AACJ,SAAA;AACJ,KAAA;;AAGD,IAAA,gBAAgB,EAAE,IAAI;;AAEtB,IAAA,mBAAmB,EAAE,IAAI;;;AAIzB,IAAA,SAAS,EAAE,KAAK;;AAGhB,IAAA,WAAW,EAAE,EAAE;;IAGf,OAAO,CAAC,MAAM,EAAA,GAAI;;IAGlB,OAAO,CAAC,MAAM,EAAA,GAAI;;IAGlB,OAAO,CAAC,MAAM,EAAA,GAAI;"}
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection-broker.cjs","sources":["../../src/connectors/connection-broker.ts"],"sourcesContent":[null],"names":["GraphqlPubSubConnector","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C;KAC/C;AAED,IAAA,IAAW,eAAe,GAAA;AACtB,QAAA,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;KACzC;AAED,IAAA,IAAW,eAAe,GAAA;AACtB,QAAA,OAAO,IAAI,CAAC,eAAe,CAAC,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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;A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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"}
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,22 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongo-connector.cjs","sources":["../../src/connectors/mongo-connector.ts"],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ACtE,YAAA,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAC;AAChF,SAAC,CAAC,CAAC;AAEH,QAAA,IACIC,gBAAM,CAAC,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"}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;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