@rxap/nest-keyv-minio 10.0.0-dev.1 → 10.0.0-dev.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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [10.0.0-dev.4](https://gitlab.com/rxap/packages/compare/@rxap/nest-keyv-minio@10.0.0-dev.3...@rxap/nest-keyv-minio@10.0.0-dev.4) (2025-02-19)
7
+
8
+ ### Bug Fixes
9
+
10
+ - update package groups ([5b3aa54](https://gitlab.com/rxap/packages/commit/5b3aa54554582462026df82a4d3e79b89dacdf05))
11
+
12
+ # [10.0.0-dev.3](https://gitlab.com/rxap/packages/compare/@rxap/nest-keyv-minio@10.0.0-dev.2...@rxap/nest-keyv-minio@10.0.0-dev.3) (2025-02-19)
13
+
14
+ ### Bug Fixes
15
+
16
+ - use correct default bucket name ([62767b5](https://gitlab.com/rxap/packages/commit/62767b5b7a582f21c925ce84e3212a9656f6ec1a))
17
+
18
+ # [10.0.0-dev.2](https://gitlab.com/rxap/packages/compare/@rxap/nest-keyv-minio@10.0.0-dev.1...@rxap/nest-keyv-minio@10.0.0-dev.2) (2025-02-18)
19
+
20
+ **Note:** Version bump only for package @rxap/nest-keyv-minio
21
+
6
22
  # 10.0.0-dev.1 (2025-02-18)
7
23
 
8
24
  **Note:** Version bump only for package @rxap/nest-keyv-minio
package/README.md CHANGED
@@ -19,7 +19,7 @@ yarn add @rxap/nest-keyv-minio
19
19
  ```
20
20
  **Install peer dependencies:**
21
21
  ```bash
22
- yarn add @nestjs/cache-manager@^2.2.2 @nestjs/common@^10.3.8 @rxap/nest-utilities@^10.4.1-dev.0 keyv@^5.1.0 minio@^8.0.1
22
+ yarn add @nestjs/cache-manager@^2.2.2 @nestjs/common@^10.3.8 @rxap/nest-utilities@^10.4.1-dev.1 keyv@^5.1.0 minio@^8.0.1
23
23
  ```
24
24
  **Execute the init generator:**
25
25
  ```bash
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "10.0.0-dev.1",
2
+ "version": "10.0.0-dev.4",
3
3
  "name": "@rxap/nest-keyv-minio",
4
4
  "description": "A NestJS cache module that utilizes MinIO as a storage adapter for Keyv. It provides a simple way to integrate MinIO with NestJS caching, allowing you to store cached data in a MinIO bucket. This package includes a Keyv adapter and a module options factory for easy configuration.\n",
5
5
  "license": "GPL-3.0-or-later",
@@ -10,7 +10,7 @@
10
10
  "peerDependencies": {
11
11
  "@nestjs/cache-manager": "^2.2.2",
12
12
  "@nestjs/common": "^10.3.8",
13
- "@rxap/nest-utilities": "^10.4.1-dev.0",
13
+ "@rxap/nest-utilities": "^10.4.1-dev.1",
14
14
  "keyv": "^5.1.0",
15
15
  "minio": "^8.0.1"
16
16
  },
@@ -42,5 +42,5 @@
42
42
  },
43
43
  "type": "commonjs",
44
44
  "types": "./src/index.d.ts",
45
- "gitHead": "fbe5802c409890f0835add70ec647e1b58b1f070"
45
+ "gitHead": "8058138ff98d9e37b711846892c79ebc45ed17d4"
46
46
  }
package/src/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './lib/keyv-minio-validation-schema';
1
2
  export * from './lib/keyv-minio';
2
3
  export * from './lib/minio-cache-module-options-factory';
package/src/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  // region
5
+ tslib_1.__exportStar(require("./lib/keyv-minio-validation-schema"), exports);
5
6
  tslib_1.__exportStar(require("./lib/keyv-minio"), exports);
6
7
  tslib_1.__exportStar(require("./lib/minio-cache-module-options-factory"), exports);
7
8
  // endregion
@@ -0,0 +1,3 @@
1
+ import { Environment } from '@rxap/nest-utilities';
2
+ import * as Joi from 'joi';
3
+ export declare function keyvMinioValidationSchema(environment: Environment): Joi.PartialSchemaMap<any>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.keyvMinioValidationSchema = keyvMinioValidationSchema;
4
+ const Joi = require("joi");
5
+ function keyvMinioValidationSchema(environment) {
6
+ const schema = {};
7
+ schema['KEYV_MINIO_END_POINT'] = Joi.string().default('minio');
8
+ schema['KEYV_MINIO_PORT'] = Joi.number().default(9000);
9
+ schema['KEYV_MINIO_USE_SSL'] = Joi.boolean().default(false);
10
+ schema['KEYV_MINIO_ACCESS_KEY'] = Joi.string().default('minioadmin');
11
+ schema['KEYV_MINIO_SECRET_KEY'] = Joi.string().default('minioadmin');
12
+ schema['KEYV_MINIO_BUCKET_NAME'] = Joi.string().default('keyv');
13
+ schema['KEYV_MINIO_PATH_PREFIX'] = Joi.string().default(environment.app);
14
+ return schema;
15
+ }
@@ -2,6 +2,7 @@ import { KeyvStoreAdapter, StoredData } from 'keyv';
2
2
  import { ClientOptions } from 'minio';
3
3
  export interface KeyvMinioOptions extends ClientOptions {
4
4
  bucketName: string;
5
+ pathPrefix?: string;
5
6
  }
6
7
  export declare class KeyvMinio implements KeyvStoreAdapter {
7
8
  private readonly options;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KeyvMinio = void 0;
4
4
  const minio_1 = require("minio");
5
+ const path_1 = require("path");
5
6
  class KeyvMinio {
6
7
  constructor(options) {
7
8
  this.options = options;
@@ -11,8 +12,9 @@ class KeyvMinio {
11
12
  return this.options.bucketName;
12
13
  }
13
14
  async get(key) {
15
+ const filePath = (0, path_1.join)(this.options.pathPrefix ?? '', key + '.json');
14
16
  try {
15
- const dataStream = await this.client.getObject(this.bucketName, key + '.json');
17
+ const dataStream = await this.client.getObject(this.bucketName, filePath);
16
18
  let data = '';
17
19
  for await (const chunk of dataStream) {
18
20
  data += chunk.toString();
@@ -23,15 +25,17 @@ class KeyvMinio {
23
25
  if (error.code === 'NoSuchKey') {
24
26
  return undefined;
25
27
  }
26
- throw new Error(`Error getting minio object in bucket ${this.bucketName} with key ${key + '.json'}: (${error.code}) ${error.message}`);
28
+ throw new Error(`Error getting minio object in bucket ${this.bucketName} with key ${filePath}: (${error.code}) ${error.message}`);
27
29
  }
28
30
  }
29
31
  async set(key, value, ttl) {
30
- await this.client.putObject(this.bucketName, key + '.json', JSON.stringify({ value, expires: ttl ? Date.now() + ttl : null }), undefined);
32
+ const filePath = (0, path_1.join)(this.options.pathPrefix ?? '', key + '.json');
33
+ await this.client.putObject(this.bucketName, filePath, JSON.stringify({ value, expires: ttl ? Date.now() + ttl : null }), undefined);
31
34
  }
32
35
  async delete(key) {
36
+ const filePath = (0, path_1.join)(this.options.pathPrefix ?? '', key + '.json');
33
37
  try {
34
- await this.client.removeObject(this.bucketName, key);
38
+ await this.client.removeObject(this.bucketName, filePath);
35
39
  }
36
40
  catch (error) {
37
41
  if (error.code === 'NoSuchKey') {
@@ -43,7 +47,7 @@ class KeyvMinio {
43
47
  async clear() {
44
48
  try {
45
49
  // Use the listObjectsV2 method to get a list of objects in the bucket
46
- const stream = this.client.listObjectsV2(this.bucketName, '', true);
50
+ const stream = this.client.listObjectsV2(this.bucketName, this.options.pathPrefix ?? '', true);
47
51
  await new Promise((resolve, reject) => {
48
52
  // Array to hold promises for object deletions
49
53
  const deletePromises = [];
@@ -2,5 +2,5 @@ import { CacheOptions } from '@nestjs/cache-manager';
2
2
  import { KeyvMinioOptions } from './keyv-minio';
3
3
  import { CacheModuleOptionsLoader } from '@rxap/nest-utilities';
4
4
  export declare class MinioCacheModuleOptionsFactory extends CacheModuleOptionsLoader<KeyvMinioOptions> {
5
- createCacheOptions(): CacheOptions<KeyvMinioOptions>;
5
+ createCacheOptions(): Promise<CacheOptions<KeyvMinioOptions>> | CacheOptions<KeyvMinioOptions>;
6
6
  }
@@ -49,12 +49,13 @@ let MinioCacheModuleOptionsFactory = class MinioCacheModuleOptionsFactory extend
49
49
  createCacheOptions() {
50
50
  return {
51
51
  ...super.createCacheOptions(),
52
- endPoint: this.config.getOrThrow('MINIO_END_POINT'),
53
- port: this.config.get('MINIO_PORT', 9000),
54
- useSSL: this.config.get('MINIO_USE_SSL', false),
55
- accessKey: this.config.getOrThrow('MINIO_ACCESS_KEY'),
56
- secretKey: this.config.getOrThrow('MINIO_SECRET_KEY'),
57
- bucketName: this.config.get('MINIO_BUCKET_NAME', 'keyv'),
52
+ endPoint: this.config.get('KEYV_MINIO_END_POINT', 'minio'),
53
+ port: this.config.get('KEYV_MINIO_PORT', 9000),
54
+ useSSL: this.config.get('KEYV_MINIO_USE_SSL', false),
55
+ accessKey: this.config.get('KEYV_MINIO_ACCESS_KEY', 'minioadmin'),
56
+ secretKey: this.config.get('KEYV_MINIO_SECRET_KEY', 'minioadmin'),
57
+ bucketName: this.config.get('KEYV_MINIO_BUCKET_NAME', 'keyv'),
58
+ pathPrefix: this.config.get('KEYV_MINIO_PATH_PREFIX'),
58
59
  store: (options) => new CacheStoreV6ToV5Adapter(new keyv_minio_1.KeyvMinio(options)),
59
60
  };
60
61
  }