pluga-plg 0.2.0 → 0.2.2
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
CHANGED
|
@@ -13,10 +13,10 @@ Pluga developer platform toolbox
|
|
|
13
13
|
If you are using the `storageService` (>= 0.2.0), define the following in the environment:
|
|
14
14
|
|
|
15
15
|
```env
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
SERVICE_STORAGE_S3_BUCKET=bucket-name
|
|
17
|
+
SERVICE_STORAGE_REGION=region
|
|
18
|
+
SERVICE_STORAGE_ACCESS_KEY_ID=access-key
|
|
19
|
+
SERVICE_STORAGE_SECRET_ACCESS_KEY=secret-key
|
|
20
20
|
```
|
|
21
21
|
## plg.errors
|
|
22
22
|
|
|
@@ -7,17 +7,6 @@ describe('Storage service', () => {
|
|
|
7
7
|
const successResp = { success: true };
|
|
8
8
|
let streamFileWriter;
|
|
9
9
|
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
client = {
|
|
12
|
-
upload: jest.fn(),
|
|
13
|
-
download: jest.fn(),
|
|
14
|
-
fileExists: jest.fn(),
|
|
15
|
-
getSignedUrl: jest.fn(),
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
service = new StorageService(client);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
10
|
beforeEach(() => {
|
|
22
11
|
client = {
|
|
23
12
|
upload: jest.fn(),
|
|
@@ -50,7 +39,7 @@ describe('Storage service', () => {
|
|
|
50
39
|
const stream = { fake: 'stream' };
|
|
51
40
|
const expectedResult = { success: true };
|
|
52
41
|
|
|
53
|
-
client.download.
|
|
42
|
+
client.download.mockResolvedValue({ stream });
|
|
54
43
|
streamFileWriter.writeToDisk.mockResolvedValue(expectedResult);
|
|
55
44
|
|
|
56
45
|
const result = await service.download(params);
|
|
@@ -16,12 +16,12 @@ class S3Service {
|
|
|
16
16
|
#bucket;
|
|
17
17
|
|
|
18
18
|
constructor({ client = null, bucket = null } = {}) {
|
|
19
|
-
this.#bucket = bucket || process.env.
|
|
19
|
+
this.#bucket = bucket || process.env.SERVICE_STORAGE_S3_BUCKET;
|
|
20
20
|
this.#client = client || new S3Client({
|
|
21
|
-
region: process.env.
|
|
21
|
+
region: process.env.SERVICE_STORAGE_REGION,
|
|
22
22
|
credentials: {
|
|
23
|
-
accessKeyId: process.env.
|
|
24
|
-
secretAccessKey: process.env.
|
|
23
|
+
accessKeyId: process.env.SERVICE_STORAGE_ACCESS_KEY_ID,
|
|
24
|
+
secretAccessKey: process.env.SERVICE_STORAGE_SECRET_ACCESS_KEY,
|
|
25
25
|
},
|
|
26
26
|
});
|
|
27
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pluga-plg",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Pluga developer platform toolbox",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Pluga <tech@pluga.co> (pluga.co)",
|
|
@@ -25,4 +25,4 @@
|
|
|
25
25
|
"eslint-config-airbnb-base": "15.0.0",
|
|
26
26
|
"eslint-plugin-import": "2.29.1"
|
|
27
27
|
}
|
|
28
|
-
}
|
|
28
|
+
}
|