@takentrade/takentrade-libs 1.0.6 → 1.0.7

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.
@@ -1,14 +1,10 @@
1
- /**
2
- * Configuration utility for setting up the Cloudinary client in a NestJS application.
3
- * This module provides a function to configure the Cloudinary SDK using environment variables.
4
- * @module cloudinary.storage
5
- */
6
1
  import { ConfigService } from '@nestjs/config';
7
- import { v2 as cloudinary } from 'cloudinary';
8
- /**
9
- * Configures the Cloudinary client with credentials from environment variables.
10
- * @param configService - The NestJS ConfigService instance to retrieve environment variables.
11
- * @returns The configured Cloudinary v2 instance.
12
- * @throws Error if required environment variables are not set.
13
- */
14
- export declare const configureCloudinary: (configService: ConfigService) => typeof cloudinary;
2
+ export declare class CloudinaryConfig {
3
+ private readonly configService;
4
+ constructor(configService: ConfigService);
5
+ createSharedConfiguration(): {
6
+ cloud_name: string | undefined;
7
+ api_key: string | undefined;
8
+ api_secret: string | undefined;
9
+ };
10
+ }
@@ -1,24 +1,20 @@
1
1
  "use strict";
2
- /**
3
- * Configuration utility for setting up the Cloudinary client in a NestJS application.
4
- * This module provides a function to configure the Cloudinary SDK using environment variables.
5
- * @module cloudinary.storage
6
- */
7
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.configureCloudinary = void 0;
3
+ exports.CloudinaryConfig = void 0;
9
4
  const cloudinary_1 = require("cloudinary");
10
- /**
11
- * Configures the Cloudinary client with credentials from environment variables.
12
- * @param configService - The NestJS ConfigService instance to retrieve environment variables.
13
- * @returns The configured Cloudinary v2 instance.
14
- * @throws Error if required environment variables are not set.
15
- */
16
- const configureCloudinary = (configService) => {
17
- cloudinary_1.v2.config({
18
- cloud_name: configService.get('CLOUDINARY_CLOUD_NAME'),
19
- api_key: configService.get('CLOUDINARY_API_KEY'),
20
- api_secret: configService.get('CLOUDINARY_API_SECRET'),
21
- });
22
- return cloudinary_1.v2;
23
- };
24
- exports.configureCloudinary = configureCloudinary;
5
+ class CloudinaryConfig {
6
+ configService;
7
+ constructor(configService) {
8
+ this.configService = configService;
9
+ }
10
+ createSharedConfiguration() {
11
+ const config = {
12
+ cloud_name: this.configService.get('CLOUDINARY_CLOUD_NAME'),
13
+ api_key: this.configService.get('CLOUDINARY_API_KEY'),
14
+ api_secret: this.configService.get('CLOUDINARY_API_SECRET'),
15
+ };
16
+ cloudinary_1.v2.config(config);
17
+ return config;
18
+ }
19
+ }
20
+ exports.CloudinaryConfig = CloudinaryConfig;
@@ -1,2 +1,4 @@
1
+ import { DynamicModule } from '@nestjs/common';
1
2
  export declare class StorageModule {
3
+ static register(): DynamicModule;
2
4
  }
@@ -5,18 +5,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var StorageModule_1;
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.StorageModule = void 0;
10
11
  const common_1 = require("@nestjs/common");
11
- const storage_service_1 = require("./storage.service");
12
12
  const config_1 = require("@nestjs/config");
13
- let StorageModule = class StorageModule {
13
+ const storage_service_1 = require("./storage.service");
14
+ const cloudinary_storage_1 = require("./cloudinary.storage");
15
+ let StorageModule = StorageModule_1 = class StorageModule {
16
+ static register() {
17
+ return {
18
+ module: StorageModule_1,
19
+ imports: [config_1.ConfigModule],
20
+ providers: [storage_service_1.StorageService, cloudinary_storage_1.CloudinaryConfig],
21
+ exports: [storage_service_1.StorageService],
22
+ };
23
+ }
14
24
  };
15
25
  exports.StorageModule = StorageModule;
16
- exports.StorageModule = StorageModule = __decorate([
17
- (0, common_1.Module)({
18
- imports: [config_1.ConfigModule],
19
- providers: [storage_service_1.StorageService],
20
- exports: [storage_service_1.StorageService],
21
- })
26
+ exports.StorageModule = StorageModule = StorageModule_1 = __decorate([
27
+ (0, common_1.Module)({})
22
28
  ], StorageModule);
@@ -1,15 +1,8 @@
1
- import { ConfigService } from '@nestjs/config';
2
1
  import { IStorageService, UploadResponse, DeleteResponse } from './storage.interface';
3
- /**
4
- * Service class for interacting with Cloudinary to manage file uploads and deletions.
5
- */
2
+ import { CloudinaryConfig } from './cloudinary.storage';
6
3
  export declare class StorageService implements IStorageService {
7
- private configService;
8
- /**
9
- * Initializes the service and configures Cloudinary with environment variables.
10
- * @param configService - The NestJS ConfigService to access environment variables.
11
- */
12
- constructor(configService: ConfigService);
4
+ private cloudinaryConfig;
5
+ constructor(cloudinaryConfig: CloudinaryConfig);
13
6
  /**
14
7
  * Uploads a file to Cloudinary using a stream.
15
8
  * @param file - The file to upload, provided as an Express.Multer.File object.
@@ -9,19 +9,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.StorageService = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
11
  const cloudinary_1 = require("cloudinary");
12
- const cloudinary_storage_1 = require("./cloudinary.storage");
13
- /**
14
- * Service class for interacting with Cloudinary to manage file uploads and deletions.
15
- */
16
12
  let StorageService = class StorageService {
17
- configService;
18
- /**
19
- * Initializes the service and configures Cloudinary with environment variables.
20
- * @param configService - The NestJS ConfigService to access environment variables.
21
- */
22
- constructor(configService) {
23
- this.configService = configService;
24
- (0, cloudinary_storage_1.configureCloudinary)(configService);
13
+ cloudinaryConfig;
14
+ constructor(cloudinaryConfig) {
15
+ this.cloudinaryConfig = cloudinaryConfig;
16
+ this.cloudinaryConfig.createSharedConfiguration();
25
17
  }
26
18
  /**
27
19
  * Uploads a file to Cloudinary using a stream.