@cap-js-community/common 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -77,6 +77,22 @@ Options can be passed to replication cache via CDS environment via `cds.replicat
77
77
  - `tmpDir: Boolean`: Store replication cache file in temporary directory. Default is `false`
78
78
  - `baseDir: String`: Base directory for replication cache files. Default is `"temp"`
79
79
 
80
+ ### Test
81
+
82
+ Replication cache is inactive per default for tests (`test` profile). It can be enabled via CDS env:
83
+
84
+ ```json
85
+ {
86
+ "cds": {
87
+ "replicationCache": {
88
+ "[test]": {
89
+ "plugin": true
90
+ }
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
80
96
  ## Migration Check
81
97
 
82
98
  ### Options
@@ -201,6 +217,22 @@ For shared redis configuration Redis service name can be provided in CDS env as
201
217
  }
202
218
  ```
203
219
 
220
+ ### Test
221
+
222
+ Rate limiting is inactive per default for tests (`test` profile). It can be enabled via CDS env:
223
+
224
+ ```json
225
+ {
226
+ "cds": {
227
+ "rateLimiting": {
228
+ "[test]": {
229
+ "plugin": true
230
+ }
231
+ }
232
+ }
233
+ }
234
+ ```
235
+
204
236
  ## Redis Client
205
237
 
206
238
  A Redis Client broker is provided to connect to Redis service.
@@ -225,7 +257,7 @@ const mainClient = await RedisClient.default("name").createMainClientAndConnect(
225
257
 
226
258
  ```js
227
259
  const { RedisClient } = require("@cap-js-community/common");
228
- const client = await new RedisClient(name).createClientAndConnect(options);
260
+ const client = await new RedisClient("name").createClientAndConnect(options);
229
261
  ```
230
262
 
231
263
  ### Options
@@ -248,6 +280,28 @@ Redis options can be provided in CDS env as follows:
248
280
  }
249
281
  ```
250
282
 
283
+ Specific Redis options for a custom name can be established as follows:
284
+
285
+ ```json
286
+ {
287
+ "cds": {
288
+ "requires": {
289
+ "redis-customName": {
290
+ "vcap": {
291
+ "tag": "redis-cache"
292
+ },
293
+ "options": {}
294
+ }
295
+ }
296
+ }
297
+ }
298
+ ```
299
+
300
+ ```js
301
+ const { RedisClient } = require("@cap-js-community/common");
302
+ const mainClient = await RedisClient.default("customName").createMainClientAndConnect(options);
303
+ ```
304
+
251
305
  In addition, options can be passed to Redis client during creation via `options` parameter:
252
306
 
253
307
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js-community/common",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "CAP Node.js Community Common",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "engines": {
@@ -56,7 +56,7 @@
56
56
  "@sap/cds-common-content": "^2.1.0",
57
57
  "@sap/cds-dk": "^8.9.1",
58
58
  "eslint": "9.24.0",
59
- "eslint-config-prettier": "10.1.1",
59
+ "eslint-config-prettier": "10.1.2",
60
60
  "eslint-plugin-jest": "28.11.0",
61
61
  "eslint-plugin-n": "^17.17.0",
62
62
  "jest": "29.7.0",
@@ -184,6 +184,9 @@ class RedisClient {
184
184
  }
185
185
 
186
186
  async closeMainClient() {
187
+ if (!this.mainClientPromise) {
188
+ return;
189
+ }
187
190
  const client = this.mainClientPromise;
188
191
  this.mainClientPromise = null;
189
192
  await this.resilientClientClose(await client);
@@ -191,6 +194,9 @@ class RedisClient {
191
194
  }
192
195
 
193
196
  async closeAdditionalClient() {
197
+ if (!this.additionalClientPromise) {
198
+ return;
199
+ }
194
200
  const client = this.additionalClientPromise;
195
201
  this.additionalClientPromise = null;
196
202
  await this.resilientClientClose(await client);
@@ -198,6 +204,9 @@ class RedisClient {
198
204
  }
199
205
 
200
206
  async closeSubscribeClient() {
207
+ if (!this.subscriberClientPromise) {
208
+ return;
209
+ }
201
210
  const client = this.subscriberClientPromise;
202
211
  this.subscriberClientPromise = null;
203
212
  await this.resilientClientClose(await client);