@nextage/nx-frame-be 1.0.31 → 1.0.33
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.
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AWSBaseConfig, AWSS3Config } from './aws.interfaces';
|
|
2
|
+
export declare class AWSS3Manager {
|
|
3
|
+
private readonly config;
|
|
4
|
+
private readonly s3;
|
|
5
|
+
private readonly bucket;
|
|
6
|
+
private readonly baseUrl;
|
|
7
|
+
constructor({ bucket, baseUrl }: AWSS3Config | undefined, config: AWSBaseConfig);
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param contentType
|
|
11
|
+
* @param path
|
|
12
|
+
* @param filename
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
getSignedUrl(contentType: string, path?: string, urlpath?: string, filename?: string): Promise<{
|
|
16
|
+
uploadUrl: string;
|
|
17
|
+
fileUrl: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AWSS3Manager = void 0;
|
|
13
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
14
|
+
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
15
|
+
const common_1 = require("../common");
|
|
16
|
+
class AWSS3Manager {
|
|
17
|
+
constructor({ bucket, baseUrl } = { bucket: 'data' }, config) {
|
|
18
|
+
this.config = config || { region: 'eu-south-1' };
|
|
19
|
+
this.s3 = new client_s3_1.S3Client({ region: this.config.region, requestChecksumCalculation: 'WHEN_REQUIRED' });
|
|
20
|
+
this.bucket = bucket;
|
|
21
|
+
this.baseUrl = baseUrl !== null && baseUrl !== void 0 ? baseUrl : `https://${bucket}.s3.amazonaws.com`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param contentType
|
|
26
|
+
* @param path
|
|
27
|
+
* @param filename
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
getSignedUrl(contentType_1) {
|
|
31
|
+
return __awaiter(this, arguments, void 0, function* (contentType, path = 'images', urlpath = '', filename) {
|
|
32
|
+
if (!filename)
|
|
33
|
+
filename = (0, common_1.uuid)();
|
|
34
|
+
const key = `${path}/${filename}`;
|
|
35
|
+
const command = new client_s3_1.PutObjectCommand({
|
|
36
|
+
Bucket: this.bucket,
|
|
37
|
+
Key: key,
|
|
38
|
+
ContentType: contentType,
|
|
39
|
+
});
|
|
40
|
+
// expires in 1 minute
|
|
41
|
+
const uploadUrl = yield (0, s3_request_presigner_1.getSignedUrl)(this.s3, command, { expiresIn: 60 });
|
|
42
|
+
const fileUrl = `${urlpath}/${filename}`;
|
|
43
|
+
return { uploadUrl, fileUrl };
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.AWSS3Manager = AWSS3Manager;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export interface AWSBaseConfig {
|
|
2
2
|
region?: string;
|
|
3
|
+
credentials?: {
|
|
4
|
+
accessKeyId: string;
|
|
5
|
+
secretAccessKey: string;
|
|
6
|
+
};
|
|
3
7
|
}
|
|
4
8
|
export interface AWSClusterConfig {
|
|
5
9
|
cluster: string;
|
|
@@ -37,3 +41,7 @@ export interface AWSQueueConfig {
|
|
|
37
41
|
visibilityTimeout?: number;
|
|
38
42
|
heartbeatInterval?: number;
|
|
39
43
|
}
|
|
44
|
+
export interface AWSS3Config {
|
|
45
|
+
bucket: string;
|
|
46
|
+
baseUrl?: string;
|
|
47
|
+
}
|
package/build/aws/index.d.ts
CHANGED
package/build/aws/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./aws.interfaces"), exports);
|
|
18
18
|
__exportStar(require("./aws-cluster-manager"), exports);
|
|
19
19
|
__exportStar(require("./aws-email-manager"), exports);
|
|
20
|
+
__exportStar(require("./aws-s3-manager"), exports);
|
|
20
21
|
__exportStar(require("./aws-queue-manager"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextage/nx-frame-be",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -28,8 +28,10 @@
|
|
|
28
28
|
"@apollo/server-plugin-landing-page-graphql-playground": "^4.0.1",
|
|
29
29
|
"@apollo/subgraph": "^2.11.2",
|
|
30
30
|
"@aws-sdk/client-ecs": "^3.592.0",
|
|
31
|
+
"@aws-sdk/client-s3": "^3.1017.0",
|
|
31
32
|
"@aws-sdk/client-ses": "^3.592.0",
|
|
32
33
|
"@aws-sdk/client-sqs": "^3.592.0",
|
|
34
|
+
"@aws-sdk/s3-request-presigner": "^3.1017.0",
|
|
33
35
|
"@types/async": "^3.2.24",
|
|
34
36
|
"@types/cookie-session": "^2.0.49",
|
|
35
37
|
"@types/crypto-js": "^4.2.2",
|