@takentrade/takentrade-libs 1.0.7 → 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/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -3
- package/dist/storage/cloudinary.storage.d.ts +0 -10
- package/dist/storage/cloudinary.storage.js +0 -20
- package/dist/storage/index.d.ts +0 -4
- package/dist/storage/index.js +0 -20
- package/dist/storage/storage.interface.d.ts +0 -20
- package/dist/storage/storage.interface.js +0 -7
- package/dist/storage/storage.module.d.ts +0 -4
- package/dist/storage/storage.module.js +0 -28
- package/dist/storage/storage.service.d.ts +0 -20
- package/dist/storage/storage.service.js +0 -69
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takentrade/takentrade-libs",
|
|
3
|
-
"version": "1.0.
|
|
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,10 +0,0 @@
|
|
|
1
|
-
import { ConfigService } from '@nestjs/config';
|
|
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,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CloudinaryConfig = void 0;
|
|
4
|
-
const cloudinary_1 = require("cloudinary");
|
|
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;
|
package/dist/storage/index.d.ts
DELETED
package/dist/storage/index.js
DELETED
|
@@ -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,28 +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
|
-
var StorageModule_1;
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.StorageModule = void 0;
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const config_1 = require("@nestjs/config");
|
|
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
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.StorageModule = StorageModule;
|
|
26
|
-
exports.StorageModule = StorageModule = StorageModule_1 = __decorate([
|
|
27
|
-
(0, common_1.Module)({})
|
|
28
|
-
], StorageModule);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { IStorageService, UploadResponse, DeleteResponse } from './storage.interface';
|
|
2
|
-
import { CloudinaryConfig } from './cloudinary.storage';
|
|
3
|
-
export declare class StorageService implements IStorageService {
|
|
4
|
-
private cloudinaryConfig;
|
|
5
|
-
constructor(cloudinaryConfig: CloudinaryConfig);
|
|
6
|
-
/**
|
|
7
|
-
* Uploads a file to Cloudinary using a stream.
|
|
8
|
-
* @param file - The file to upload, provided as an Express.Multer.File object.
|
|
9
|
-
* @returns A promise resolving to the upload response containing file details.
|
|
10
|
-
* @throws Error if the upload fails or no result is returned from Cloudinary.
|
|
11
|
-
*/
|
|
12
|
-
uploadFile(file: Express.Multer.File): Promise<UploadResponse>;
|
|
13
|
-
/**
|
|
14
|
-
* Deletes a file from Cloudinary using its public ID.
|
|
15
|
-
* @param publicId - The public ID of the file to delete.
|
|
16
|
-
* @returns A promise resolving to the deletion response.
|
|
17
|
-
* @throws Error if the deletion fails.
|
|
18
|
-
*/
|
|
19
|
-
deleteFile(publicId: string): Promise<DeleteResponse>;
|
|
20
|
-
}
|
|
@@ -1,69 +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
|
-
let StorageService = class StorageService {
|
|
13
|
-
cloudinaryConfig;
|
|
14
|
-
constructor(cloudinaryConfig) {
|
|
15
|
-
this.cloudinaryConfig = cloudinaryConfig;
|
|
16
|
-
this.cloudinaryConfig.createSharedConfiguration();
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Uploads a file to Cloudinary using a stream.
|
|
20
|
-
* @param file - The file to upload, provided as an Express.Multer.File object.
|
|
21
|
-
* @returns A promise resolving to the upload response containing file details.
|
|
22
|
-
* @throws Error if the upload fails or no result is returned from Cloudinary.
|
|
23
|
-
*/
|
|
24
|
-
async uploadFile(file) {
|
|
25
|
-
try {
|
|
26
|
-
const result = await new Promise((resolve, reject) => {
|
|
27
|
-
cloudinary_1.v2.uploader
|
|
28
|
-
.upload_stream({ resource_type: 'auto' }, (error, result) => {
|
|
29
|
-
if (error)
|
|
30
|
-
return reject(error);
|
|
31
|
-
if (!result)
|
|
32
|
-
return reject(new Error('No result from Cloudinary'));
|
|
33
|
-
resolve(result);
|
|
34
|
-
})
|
|
35
|
-
.end(file.buffer);
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
public_id: result.public_id,
|
|
39
|
-
url: result.url,
|
|
40
|
-
secure_url: result.secure_url,
|
|
41
|
-
format: result.format,
|
|
42
|
-
resource_type: result.resource_type,
|
|
43
|
-
created_at: result.created_at,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
throw new Error(`Upload failed: ${error.message}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Deletes a file from Cloudinary using its public ID.
|
|
52
|
-
* @param publicId - The public ID of the file to delete.
|
|
53
|
-
* @returns A promise resolving to the deletion response.
|
|
54
|
-
* @throws Error if the deletion fails.
|
|
55
|
-
*/
|
|
56
|
-
async deleteFile(publicId) {
|
|
57
|
-
try {
|
|
58
|
-
const result = await cloudinary_1.v2.uploader.destroy(publicId);
|
|
59
|
-
return { result: result.result };
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
throw new Error(`Deletion failed: ${error.message}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
exports.StorageService = StorageService;
|
|
67
|
-
exports.StorageService = StorageService = __decorate([
|
|
68
|
-
(0, common_1.Injectable)()
|
|
69
|
-
], StorageService);
|