@takentrade/takentrade-libs 1.0.6 → 1.0.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takentrade/takentrade-libs",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "TakeNTrade shared libraries",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -38,7 +38,6 @@
38
38
  "@prisma/client": "^6.12.0",
39
39
  "class-transformer": "^0.5.1",
40
40
  "class-validator": "^0.14.2",
41
- "cloudinary": "^2.7.0",
42
41
  "country-codes-list": "^2.0.0",
43
42
  "ioredis": "^5.6.1",
44
43
  "joi": "^17.13.3",
@@ -50,7 +49,6 @@
50
49
  "uuid": "^11.1.0"
51
50
  },
52
51
  "devDependencies": {
53
- "@types/multer": "^2.0.0",
54
52
  "@types/node": "^24.1.0",
55
53
  "@types/object-hash": "^3.0.6",
56
54
  "@types/passport": "^1.0.17",
@@ -1,14 +0,0 @@
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
- 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;
@@ -1,24 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.configureCloudinary = void 0;
9
- 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;
@@ -1,4 +0,0 @@
1
- export * from './cloudinary.storage';
2
- export * from './storage.interface';
3
- export * from './storage.module';
4
- export * from './storage.service';
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./cloudinary.storage"), exports);
18
- __exportStar(require("./storage.interface"), exports);
19
- __exportStar(require("./storage.module"), exports);
20
- __exportStar(require("./storage.service"), exports);
@@ -1,20 +0,0 @@
1
- /**
2
- * TypeScript interfaces for the Cloudinary storage module.
3
- * Defines the contract for storage service operations and response types.
4
- * @module storage.interface
5
- */
6
- export interface IStorageService {
7
- uploadFile(file: Express.Multer.File): Promise<UploadResponse>;
8
- deleteFile(publicId: string): Promise<DeleteResponse>;
9
- }
10
- export interface UploadResponse {
11
- public_id: string;
12
- url: string;
13
- secure_url: string;
14
- format: string;
15
- resource_type: string;
16
- created_at: string;
17
- }
18
- export interface DeleteResponse {
19
- result: string;
20
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * TypeScript interfaces for the Cloudinary storage module.
4
- * Defines the contract for storage service operations and response types.
5
- * @module storage.interface
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- export declare class StorageModule {
2
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.StorageModule = void 0;
10
- const common_1 = require("@nestjs/common");
11
- const storage_service_1 = require("./storage.service");
12
- const config_1 = require("@nestjs/config");
13
- let StorageModule = class StorageModule {
14
- };
15
- 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
- })
22
- ], StorageModule);
@@ -1,27 +0,0 @@
1
- import { ConfigService } from '@nestjs/config';
2
- import { IStorageService, UploadResponse, DeleteResponse } from './storage.interface';
3
- /**
4
- * Service class for interacting with Cloudinary to manage file uploads and deletions.
5
- */
6
- 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);
13
- /**
14
- * Uploads a file to Cloudinary using a stream.
15
- * @param file - The file to upload, provided as an Express.Multer.File object.
16
- * @returns A promise resolving to the upload response containing file details.
17
- * @throws Error if the upload fails or no result is returned from Cloudinary.
18
- */
19
- uploadFile(file: Express.Multer.File): Promise<UploadResponse>;
20
- /**
21
- * Deletes a file from Cloudinary using its public ID.
22
- * @param publicId - The public ID of the file to delete.
23
- * @returns A promise resolving to the deletion response.
24
- * @throws Error if the deletion fails.
25
- */
26
- deleteFile(publicId: string): Promise<DeleteResponse>;
27
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.StorageService = void 0;
10
- const common_1 = require("@nestjs/common");
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
- 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);
25
- }
26
- /**
27
- * Uploads a file to Cloudinary using a stream.
28
- * @param file - The file to upload, provided as an Express.Multer.File object.
29
- * @returns A promise resolving to the upload response containing file details.
30
- * @throws Error if the upload fails or no result is returned from Cloudinary.
31
- */
32
- async uploadFile(file) {
33
- try {
34
- const result = await new Promise((resolve, reject) => {
35
- cloudinary_1.v2.uploader
36
- .upload_stream({ resource_type: 'auto' }, (error, result) => {
37
- if (error)
38
- return reject(error);
39
- if (!result)
40
- return reject(new Error('No result from Cloudinary'));
41
- resolve(result);
42
- })
43
- .end(file.buffer);
44
- });
45
- return {
46
- public_id: result.public_id,
47
- url: result.url,
48
- secure_url: result.secure_url,
49
- format: result.format,
50
- resource_type: result.resource_type,
51
- created_at: result.created_at,
52
- };
53
- }
54
- catch (error) {
55
- throw new Error(`Upload failed: ${error.message}`);
56
- }
57
- }
58
- /**
59
- * Deletes a file from Cloudinary using its public ID.
60
- * @param publicId - The public ID of the file to delete.
61
- * @returns A promise resolving to the deletion response.
62
- * @throws Error if the deletion fails.
63
- */
64
- async deleteFile(publicId) {
65
- try {
66
- const result = await cloudinary_1.v2.uploader.destroy(publicId);
67
- return { result: result.result };
68
- }
69
- catch (error) {
70
- throw new Error(`Deletion failed: ${error.message}`);
71
- }
72
- }
73
- };
74
- exports.StorageService = StorageService;
75
- exports.StorageService = StorageService = __decorate([
76
- (0, common_1.Injectable)()
77
- ], StorageService);