@ackplus/nest-file-storage 1.0.1 → 1.1.0
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 +6 -404
- package/eslint.config.mjs +22 -0
- package/jest.config.ts +10 -0
- package/package.json +5 -62
- package/project.json +38 -0
- package/{dist/index.d.ts → src/index.ts} +0 -1
- package/src/lib/constants.ts +1 -0
- package/src/lib/file-storage.service.ts +36 -0
- package/{dist/lib/index.d.ts → src/lib/index.ts} +0 -1
- package/{dist/lib/interceptor/file-storage.interceptor.js → src/lib/interceptor/file-storage.interceptor.ts} +70 -37
- package/src/lib/nest-file-storage.module.ts +78 -0
- package/src/lib/storage/azure.storage.ts +214 -0
- package/{dist/lib/storage/local.storage.js → src/lib/storage/local.storage.ts} +96 -82
- package/{dist/lib/storage/s3.storage.js → src/lib/storage/s3.storage.ts} +107 -96
- package/src/lib/storage.factory.ts +58 -0
- package/{dist/lib/types.d.ts → src/lib/types.ts} +35 -23
- package/tsconfig.json +17 -0
- package/tsconfig.lib.json +14 -0
- package/tsconfig.spec.json +15 -0
- package/LICENSE +0 -21
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -21
- package/dist/index.js.map +0 -1
- package/dist/lib/constants.d.ts +0 -2
- package/dist/lib/constants.d.ts.map +0 -1
- package/dist/lib/constants.js +0 -5
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/file-storage.service.d.ts +0 -8
- package/dist/lib/file-storage.service.d.ts.map +0 -1
- package/dist/lib/file-storage.service.js +0 -30
- package/dist/lib/file-storage.service.js.map +0 -1
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -22
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/interceptor/file-storage.interceptor.d.ts +0 -25
- package/dist/lib/interceptor/file-storage.interceptor.d.ts.map +0 -1
- package/dist/lib/interceptor/file-storage.interceptor.js.map +0 -1
- package/dist/lib/nest-file-storage.module.d.ts +0 -9
- package/dist/lib/nest-file-storage.module.d.ts.map +0 -1
- package/dist/lib/nest-file-storage.module.js +0 -80
- package/dist/lib/nest-file-storage.module.js.map +0 -1
- package/dist/lib/storage/azure.storage.d.ts +0 -19
- package/dist/lib/storage/azure.storage.d.ts.map +0 -1
- package/dist/lib/storage/azure.storage.js +0 -189
- package/dist/lib/storage/azure.storage.js.map +0 -1
- package/dist/lib/storage/local.storage.d.ts +0 -35
- package/dist/lib/storage/local.storage.d.ts.map +0 -1
- package/dist/lib/storage/local.storage.js.map +0 -1
- package/dist/lib/storage/s3.storage.d.ts +0 -20
- package/dist/lib/storage/s3.storage.d.ts.map +0 -1
- package/dist/lib/storage/s3.storage.js.map +0 -1
- package/dist/lib/storage.factory.d.ts +0 -9
- package/dist/lib/storage.factory.d.ts.map +0 -1
- package/dist/lib/storage.factory.js +0 -82
- package/dist/lib/storage.factory.js.map +0 -1
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js +0 -10
- package/dist/lib/types.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { AzureStorageOptions, FileStorageEnum, LocalStorageOptions, S3StorageOptions, StorageOptions } from './types';
|
|
2
|
+
import { StorageEngine } from 'multer';
|
|
3
|
+
import { Storage } from './types';
|
|
4
|
+
|
|
5
|
+
export class StorageFactory {
|
|
6
|
+
private static storageInstances = new Map<string, StorageEngine & Storage>();
|
|
7
|
+
|
|
8
|
+
static async createStorage(storageType: FileStorageEnum, options: StorageOptions): Promise<StorageEngine & Storage> {
|
|
9
|
+
const cacheKey = `${storageType}-${JSON.stringify(options)}`;
|
|
10
|
+
|
|
11
|
+
// if (this.storageInstances.has(cacheKey)) {
|
|
12
|
+
// return this.storageInstances.get(cacheKey)!;
|
|
13
|
+
// }
|
|
14
|
+
|
|
15
|
+
let storageInstance: StorageEngine & Storage;
|
|
16
|
+
|
|
17
|
+
switch (storageType) {
|
|
18
|
+
case FileStorageEnum.LOCAL:
|
|
19
|
+
const { LocalStorage } = await import('./storage/local.storage');
|
|
20
|
+
storageInstance = new LocalStorage(options as LocalStorageOptions);
|
|
21
|
+
break;
|
|
22
|
+
|
|
23
|
+
case FileStorageEnum.AZURE:
|
|
24
|
+
try {
|
|
25
|
+
const { AzureStorage } = await import('./storage/azure.storage');
|
|
26
|
+
storageInstance = new AzureStorage(options as AzureStorageOptions);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
'Azure Storage SDK (@azure/storage-blob) is required when using AzureStorage. ' +
|
|
30
|
+
'Please install it: npm install @azure/storage-blob'
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
|
|
35
|
+
case FileStorageEnum.S3:
|
|
36
|
+
try {
|
|
37
|
+
const { S3Storage } = await import('./storage/s3.storage');
|
|
38
|
+
storageInstance = new S3Storage(options as S3StorageOptions);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
'AWS SDK (@aws-sdk/client-s3 and @aws-sdk/s3-request-presigner) is required when using S3Storage. ' +
|
|
42
|
+
'Please install them: npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner'
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
|
|
47
|
+
default:
|
|
48
|
+
throw new Error(`Unsupported storage type: ${storageType}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.storageInstances.set(cacheKey, storageInstance);
|
|
52
|
+
return storageInstance;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static clearCache() {
|
|
56
|
+
this.storageInstances.clear();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
2
2
|
import { Request } from 'express';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export enum FileStorageEnum {
|
|
6
|
+
LOCAL = 'local',
|
|
7
|
+
S3 = 's3',
|
|
8
|
+
AZURE = 'azure',
|
|
7
9
|
}
|
|
10
|
+
|
|
8
11
|
export interface FileStorageOptions {
|
|
9
12
|
prefix?: string;
|
|
10
|
-
fileName?: (file: any, req: Request) => string;
|
|
11
|
-
fileDist?: (file: any, req: Request) => string;
|
|
13
|
+
fileName?: (file: any, req: Request) => string; // Custom file key
|
|
14
|
+
fileDist?: (file: any, req: Request) => string; // Custom file dist
|
|
12
15
|
transformUploadedFileObject?: (file: any) => any;
|
|
13
16
|
}
|
|
17
|
+
|
|
14
18
|
export interface S3StorageOptions extends FileStorageOptions {
|
|
15
19
|
accessKeyId: string;
|
|
16
20
|
secretAccessKey: string;
|
|
@@ -19,31 +23,36 @@ export interface S3StorageOptions extends FileStorageOptions {
|
|
|
19
23
|
endpoint?: string;
|
|
20
24
|
cloudFrontUrl?: string;
|
|
21
25
|
}
|
|
26
|
+
|
|
22
27
|
export interface LocalStorageOptions extends FileStorageOptions {
|
|
23
28
|
rootPath: string;
|
|
24
29
|
baseUrl: string;
|
|
25
30
|
}
|
|
31
|
+
|
|
26
32
|
export interface AzureStorageOptions extends FileStorageOptions {
|
|
27
33
|
account: string;
|
|
28
34
|
accountKey: string;
|
|
29
35
|
container: string;
|
|
30
36
|
}
|
|
37
|
+
|
|
31
38
|
export type StorageOptions = S3StorageOptions | AzureStorageOptions | LocalStorageOptions;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
storage: FileStorageEnum.S3;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
azureConfig: AzureStorageOptions;
|
|
41
|
-
};
|
|
39
|
+
|
|
40
|
+
// Define discriminated union types - Configuration-based approach
|
|
41
|
+
export type FileStorageConfigOptions =
|
|
42
|
+
| { storage: FileStorageEnum.LOCAL; localConfig: LocalStorageOptions; }
|
|
43
|
+
| { storage: FileStorageEnum.S3; s3Config: S3StorageOptions; }
|
|
44
|
+
| { storage: FileStorageEnum.AZURE; azureConfig: AzureStorageOptions; };
|
|
45
|
+
|
|
46
|
+
// Class factory approach - for direct storage instance usage
|
|
42
47
|
export interface FileStorageClassOptions {
|
|
43
48
|
storageFactory: () => Promise<new (...args: any[]) => Storage> | (new (...args: any[]) => Storage);
|
|
44
49
|
options?: any;
|
|
45
50
|
}
|
|
51
|
+
|
|
52
|
+
// Combined module options
|
|
46
53
|
export type FileStorageModuleOptions = FileStorageConfigOptions | FileStorageClassOptions;
|
|
54
|
+
|
|
55
|
+
|
|
47
56
|
export interface FileStorageAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
48
57
|
/**
|
|
49
58
|
* The `useExisting` syntax allows you to create aliases for existing providers.
|
|
@@ -63,22 +72,26 @@ export interface FileStorageAsyncOptions extends Pick<ModuleMetadata, 'imports'>
|
|
|
63
72
|
*/
|
|
64
73
|
inject?: any[];
|
|
65
74
|
}
|
|
75
|
+
|
|
66
76
|
export interface FileStorageOptionsFactory {
|
|
67
77
|
createFileStorageOptions(): Promise<FileStorageModuleOptions> | FileStorageModuleOptions;
|
|
68
78
|
}
|
|
79
|
+
|
|
80
|
+
|
|
69
81
|
export interface UploadedFile {
|
|
70
82
|
fieldName?: string;
|
|
71
83
|
fieldname?: string;
|
|
72
84
|
fileName: string;
|
|
73
|
-
originalName: string;
|
|
74
|
-
size: number;
|
|
85
|
+
originalName: string; // original file name
|
|
86
|
+
size: number; // files in bytes
|
|
75
87
|
mimetype?: string;
|
|
76
88
|
buffer?: Buffer;
|
|
77
|
-
key: string;
|
|
78
|
-
url: string;
|
|
79
|
-
fullPath: string;
|
|
89
|
+
key: string; // path of the file in storage
|
|
90
|
+
url: string; // file public url
|
|
91
|
+
fullPath: string; // Full path of the file
|
|
80
92
|
encoding?: string;
|
|
81
93
|
}
|
|
94
|
+
|
|
82
95
|
export interface Storage {
|
|
83
96
|
getFile(key: string): Promise<Buffer> | Buffer;
|
|
84
97
|
deleteFile(key: string): Promise<void> | void;
|
|
@@ -86,6 +99,5 @@ export interface Storage {
|
|
|
86
99
|
path?(filePath: string): Promise<string> | string;
|
|
87
100
|
getUrl(key: string): Promise<string> | string;
|
|
88
101
|
getSignedUrl?(key: string, options: any): Promise<string> | string;
|
|
89
|
-
copyFile(oldKey: string, newKey: string): Promise<UploadedFile
|
|
102
|
+
copyFile(oldKey: string, newKey: string): Promise<UploadedFile>
|
|
90
103
|
}
|
|
91
|
-
//# sourceMappingURL=types.d.ts.map
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
},
|
|
7
|
+
"files": [],
|
|
8
|
+
"include": [],
|
|
9
|
+
"references": [
|
|
10
|
+
{
|
|
11
|
+
"path": "./tsconfig.lib.json"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"path": "./tsconfig.spec.json"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"types": ["node"],
|
|
7
|
+
"target": "es2021",
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"emitDecoratorMetadata": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*.ts"],
|
|
13
|
+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"moduleResolution": "node10",
|
|
7
|
+
"types": ["jest", "node"]
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"jest.config.ts",
|
|
11
|
+
"src/**/*.test.ts",
|
|
12
|
+
"src/**/*.spec.ts",
|
|
13
|
+
"src/**/*.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Ack Solutions
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,aAAa,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,21 +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("./lib/nest-file-storage.module"), exports);
|
|
18
|
-
__exportStar(require("./lib/file-storage.service"), exports);
|
|
19
|
-
__exportStar(require("./lib/interceptor/file-storage.interceptor"), exports);
|
|
20
|
-
__exportStar(require("./lib/types"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C;AAC/C,6DAA2C;AAC3C,6EAA2D;AAC3D,8CAA4B"}
|
package/dist/lib/constants.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,uBAAuB,CAAC"}
|
package/dist/lib/constants.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,oBAAoB,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FileStorageEnum, FileStorageModuleOptions } from './types';
|
|
2
|
-
export declare class FileStorageService {
|
|
3
|
-
private static options;
|
|
4
|
-
static setOptions(options: FileStorageModuleOptions): void;
|
|
5
|
-
static getOptions(): FileStorageModuleOptions;
|
|
6
|
-
static getStorage(storageType?: FileStorageEnum): Promise<import("./types").Storage>;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=file-storage.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-storage.service.d.ts","sourceRoot":"","sources":["../../src/lib/file-storage.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAqD,MAAM,SAAS,CAAC;AAGvH,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,MAAM,CAAC,OAAO,CAA2B;IAEjD,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,wBAAwB;IAInD,MAAM,CAAC,UAAU,IAAI,wBAAwB;WAIhC,UAAU,CAAC,WAAW,CAAC,EAAE,eAAe;CAmBxD"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileStorageService = void 0;
|
|
4
|
-
const storage_factory_1 = require("./storage.factory");
|
|
5
|
-
class FileStorageService {
|
|
6
|
-
static setOptions(options) {
|
|
7
|
-
FileStorageService.options = options;
|
|
8
|
-
}
|
|
9
|
-
static getOptions() {
|
|
10
|
-
return FileStorageService.options;
|
|
11
|
-
}
|
|
12
|
-
static async getStorage(storageType) {
|
|
13
|
-
const options = this.getOptions();
|
|
14
|
-
// Check if it's a class factory approach
|
|
15
|
-
if ('storageFactory' in options) {
|
|
16
|
-
const classOptions = options;
|
|
17
|
-
const StorageClass = await classOptions.storageFactory();
|
|
18
|
-
return new StorageClass(classOptions.options);
|
|
19
|
-
}
|
|
20
|
-
// Configuration-based approach
|
|
21
|
-
const configOptions = options;
|
|
22
|
-
if (!storageType) {
|
|
23
|
-
storageType = configOptions.storage;
|
|
24
|
-
}
|
|
25
|
-
const config = configOptions[`${storageType}Config`];
|
|
26
|
-
return await storage_factory_1.StorageFactory.createStorage(storageType, config);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.FileStorageService = FileStorageService;
|
|
30
|
-
//# sourceMappingURL=file-storage.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-storage.service.js","sourceRoot":"","sources":["../../src/lib/file-storage.service.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AAInD,MAAa,kBAAkB;IAI3B,MAAM,CAAC,UAAU,CAAC,OAAiC;QAC/C,kBAAkB,CAAC,OAAO,GAAG,OAAO,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,UAAU;QACb,OAAO,kBAAkB,CAAC,OAAO,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,WAA6B;QACjD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAElC,yCAAyC;QACzC,IAAI,gBAAgB,IAAI,OAAO,EAAE,CAAC;YAC9B,MAAM,YAAY,GAAG,OAAkC,CAAC;YACxD,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,cAAc,EAAE,CAAC;YACzD,OAAO,IAAI,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAClD,CAAC;QAED,+BAA+B;QAC/B,MAAM,aAAa,GAAG,OAAmC,CAAC;QAC1D,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,WAAW,GAAG,aAAa,CAAC,OAAO,CAAC;QACxC,CAAC;QACD,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,WAAW,QAAQ,CAAC,CAAC;QACrD,OAAO,MAAM,gCAAc,CAAC,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;CAEJ;AA/BD,gDA+BC"}
|
package/dist/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC"}
|
package/dist/lib/index.js
DELETED
|
@@ -1,22 +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("./nest-file-storage.module"), exports);
|
|
18
|
-
__exportStar(require("./types"), exports);
|
|
19
|
-
__exportStar(require("./storage.factory"), exports);
|
|
20
|
-
__exportStar(require("./interceptor/file-storage.interceptor"), exports);
|
|
21
|
-
__exportStar(require("./file-storage.service"), exports);
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,0CAAwB;AACxB,oDAAkC;AAClC,yEAAuD;AACvD,yDAAuC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { NestInterceptor } from '@nestjs/common';
|
|
2
|
-
import { Request } from 'express';
|
|
3
|
-
import { FileStorageEnum, StorageOptions } from '../types';
|
|
4
|
-
export type FileUploadConfig = {
|
|
5
|
-
type: 'single' | 'array' | 'fields';
|
|
6
|
-
fieldName?: string;
|
|
7
|
-
maxCount?: number;
|
|
8
|
-
fields?: {
|
|
9
|
-
name: string;
|
|
10
|
-
maxCount?: number;
|
|
11
|
-
}[];
|
|
12
|
-
};
|
|
13
|
-
export type FileStorageInterceptorOptions = {
|
|
14
|
-
fileName?: (file: any, req?: Request) => string;
|
|
15
|
-
fileDist?: (file: any, req?: Request) => string;
|
|
16
|
-
prefix?: string;
|
|
17
|
-
storageType?: FileStorageEnum;
|
|
18
|
-
storageOptions?: StorageOptions;
|
|
19
|
-
mapToRequestBody?: (file: any, fieldName: string, req?: Request) => any;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Function-based interceptor that accepts storage options dynamically.
|
|
23
|
-
*/
|
|
24
|
-
export declare function FileStorageInterceptor(fileConfig: FileUploadConfig | string, interceptorOptions?: FileStorageInterceptorOptions): NestInterceptor;
|
|
25
|
-
//# sourceMappingURL=file-storage.interceptor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-storage.interceptor.d.ts","sourceRoot":"","sources":["../../../src/lib/interceptor/file-storage.interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAiC,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMlC,OAAO,EAAE,eAAe,EAAE,cAAc,EAA0C,MAAM,UAAU,CAAC;AAGnG,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IACxC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;IAChD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,cAAc,CAAC;IAGhC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,GAAG,CAAC;CAC3E,CAAC;AA2DF;;GAEG;AACH,wBAAgB,sBAAsB,CAClC,UAAU,EAAE,gBAAgB,GAAG,MAAM,EACrC,kBAAkB,CAAC,EAAE,6BAA6B,GACnD,eAAe,CAkFjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-storage.interceptor.js","sourceRoot":"","sources":["../../../src/lib/interceptor/file-storage.interceptor.ts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C,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACtF,CAAC,CAAC,CAAC;YAEH,iDAAiD;YACjD,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAC;YAE7D,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACzB,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { FileStorageAsyncOptions, FileStorageModuleOptions } from './types';
|
|
3
|
-
export declare class NestFileStorageModule {
|
|
4
|
-
static forRoot(options: FileStorageModuleOptions): DynamicModule;
|
|
5
|
-
static forRootAsync(options: FileStorageAsyncOptions): DynamicModule;
|
|
6
|
-
private static createAsyncProviders;
|
|
7
|
-
private static createAsyncOptionsProvider;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=nest-file-storage.module.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nest-file-storage.module.d.ts","sourceRoot":"","sources":["../../src/lib/nest-file-storage.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAY,MAAM,gBAAgB,CAAC;AAIjE,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAA6B,MAAM,SAAS,CAAC;AAGvG,qBACa,qBAAqB;IAE9B,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa;IAkBhE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,aAAa;IAWpE,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAcnC,OAAO,CAAC,MAAM,CAAC,0BAA0B;CAwB5C"}
|
|
@@ -1,80 +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 NestFileStorageModule_1;
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.NestFileStorageModule = void 0;
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const constants_1 = require("./constants");
|
|
13
|
-
const file_storage_service_1 = require("./file-storage.service");
|
|
14
|
-
let NestFileStorageModule = NestFileStorageModule_1 = class NestFileStorageModule {
|
|
15
|
-
static forRoot(options) {
|
|
16
|
-
return {
|
|
17
|
-
module: NestFileStorageModule_1,
|
|
18
|
-
providers: [
|
|
19
|
-
{
|
|
20
|
-
provide: constants_1.FILE_STORAGE_OPTIONS,
|
|
21
|
-
useFactory: async () => {
|
|
22
|
-
file_storage_service_1.FileStorageService.setOptions(options); // ✅ Store globally
|
|
23
|
-
return options;
|
|
24
|
-
},
|
|
25
|
-
inject: [],
|
|
26
|
-
},
|
|
27
|
-
file_storage_service_1.FileStorageService,
|
|
28
|
-
],
|
|
29
|
-
exports: [],
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
static forRootAsync(options) {
|
|
33
|
-
const asyncProviders = this.createAsyncProviders(options);
|
|
34
|
-
return {
|
|
35
|
-
module: NestFileStorageModule_1,
|
|
36
|
-
imports: options.imports || [],
|
|
37
|
-
providers: [...asyncProviders, file_storage_service_1.FileStorageService],
|
|
38
|
-
exports: [],
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
static createAsyncProviders(options) {
|
|
42
|
-
if (options.useExisting || options.useFactory) {
|
|
43
|
-
return [this.createAsyncOptionsProvider(options)];
|
|
44
|
-
}
|
|
45
|
-
return [
|
|
46
|
-
this.createAsyncOptionsProvider(options),
|
|
47
|
-
{
|
|
48
|
-
provide: options.useClass,
|
|
49
|
-
useClass: options.useClass,
|
|
50
|
-
},
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
static createAsyncOptionsProvider(options) {
|
|
54
|
-
if (options.useFactory) {
|
|
55
|
-
return {
|
|
56
|
-
provide: constants_1.FILE_STORAGE_OPTIONS,
|
|
57
|
-
useFactory: async (...args) => {
|
|
58
|
-
const fileStorageOptions = await options.useFactory(...args);
|
|
59
|
-
file_storage_service_1.FileStorageService.setOptions(fileStorageOptions);
|
|
60
|
-
return fileStorageOptions;
|
|
61
|
-
},
|
|
62
|
-
inject: options.inject || [],
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
provide: constants_1.FILE_STORAGE_OPTIONS,
|
|
67
|
-
useFactory: async (optionsFactory) => {
|
|
68
|
-
const fileStorageOptions = await optionsFactory.createFileStorageOptions();
|
|
69
|
-
file_storage_service_1.FileStorageService.setOptions(fileStorageOptions);
|
|
70
|
-
return fileStorageOptions;
|
|
71
|
-
},
|
|
72
|
-
inject: [options.useExisting || options.useClass],
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
exports.NestFileStorageModule = NestFileStorageModule;
|
|
77
|
-
exports.NestFileStorageModule = NestFileStorageModule = NestFileStorageModule_1 = __decorate([
|
|
78
|
-
(0, common_1.Module)({})
|
|
79
|
-
], NestFileStorageModule);
|
|
80
|
-
//# sourceMappingURL=nest-file-storage.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nest-file-storage.module.js","sourceRoot":"","sources":["../../src/lib/nest-file-storage.module.ts"],"names":[],"mappings":";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AAoB;gBAC7B,UAAU,EAAE,KAAK,EAAE,GAAG,IAAW,EAAE,EAAE;oBACjC,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,UAAW,CAAC,GAAG,IAAI,CAAC,CAAC;oBAC9D,yCAAkB,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;oBAClD,OAAO,kBAAkB,CAAC;gBAC9B,CAAC;gBACD,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;aAC/B,CAAC;QACN,CAAC;QAED,OAAO;YACH,OAAO,EAAE,gCAAoB;YAC7B,UAAU,EAAE,KAAK,EAAE,cAAyC,EAAE,EAAE;gBAC5D,MAAM,kBAAkB,GAAG,MAAM,cAAc,CAAC,wBAAwB,EAAE,CAAC;gBAC3E,yCAAkB,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;gBAClD,OAAO,kBAAkB,CAAC;YAC9B,CAAC;YACD,MAAM,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,QAAS,CAAC;SACrD,CAAC;IACN,CAAC;CAEJ,CAAA;AArEY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,qBAAqB,CAqEjC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BlobSASSignatureValues } from '@azure/storage-blob';
|
|
2
|
-
import { StorageEngine } from 'multer';
|
|
3
|
-
import { AzureStorageOptions, Storage, UploadedFile } from '../types';
|
|
4
|
-
export declare class AzureStorage implements StorageEngine, Storage {
|
|
5
|
-
private options;
|
|
6
|
-
private blobServiceClient;
|
|
7
|
-
private fileNameFunction;
|
|
8
|
-
private fileDistFunction;
|
|
9
|
-
constructor(options: AzureStorageOptions);
|
|
10
|
-
_handleFile(req: any, file: any, cb: (error?: any, info?: any) => void): Promise<void>;
|
|
11
|
-
_removeFile(_req: any, file: any, cb: (error: Error | null) => void): Promise<void>;
|
|
12
|
-
getUrl(key: string): string;
|
|
13
|
-
getSignedUrl(key: string, signatureValues?: Partial<Omit<BlobSASSignatureValues, 'containerName'>>): string;
|
|
14
|
-
getFile(key: string): Promise<Buffer>;
|
|
15
|
-
putFile(buffer: Buffer, key: string): Promise<UploadedFile>;
|
|
16
|
-
deleteFile(key: string): Promise<void>;
|
|
17
|
-
copyFile(oldKey: string, newKey: string): Promise<UploadedFile>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=azure.storage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"azure.storage.d.ts","sourceRoot":"","sources":["../../../src/lib/storage/azure.storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,sBAAsB,EAKzB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAIvC,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGtE,qBAAa,YAAa,YAAW,aAAa,EAAE,OAAO;IAQ3C,OAAO,CAAC,OAAO;IAN3B,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,gBAAgB,CAAqE;IAC7F,OAAO,CAAC,gBAAgB,CAAqE;gBAGzE,OAAO,EAAE,mBAAmB;IAoB1C,WAAW,CACb,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,GAAG,EACT,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,GACtC,OAAO,CAAC,IAAI,CAAC;IA6BV,WAAW,CACb,IAAI,EAAE,GAAG,EACT,IAAI,KAAA,EACJ,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GAClC,OAAO,CAAC,IAAI,CAAC;IAahB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAK3B,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,GAAE,OAAO,CAAC,IAAI,CAA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