eip-cloud-services 1.2.0 → 1.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/package.json +4 -1
- package/src/redis.js +4 -1
- package/src/s3.js +16 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eip-cloud-services",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Houses a collection of helpers for connecting with Cloud services.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,5 +24,8 @@
|
|
|
24
24
|
"mysql": "^2.18.1",
|
|
25
25
|
"mysql2": "^3.14.4",
|
|
26
26
|
"redis": "^4.6.7"
|
|
27
|
+
},
|
|
28
|
+
"overrides": {
|
|
29
|
+
"jws": "4.0.1"
|
|
27
30
|
}
|
|
28
31
|
}
|
package/src/redis.js
CHANGED
|
@@ -36,7 +36,10 @@ const getClient = async ( clientId = 'main' ) => {
|
|
|
36
36
|
port: node.port
|
|
37
37
|
} ) );
|
|
38
38
|
|
|
39
|
-
redisClient = new Redis.Cluster ( clusterNodes
|
|
39
|
+
redisClient = new Redis.Cluster ( clusterNodes, {
|
|
40
|
+
dnsLookup: (address, callback) => callback(null, address),
|
|
41
|
+
redisOptions: config?.redis?.options || {tls: {} }
|
|
42
|
+
} );
|
|
40
43
|
|
|
41
44
|
// Await until the cluster is ready
|
|
42
45
|
await new Promise ( ( resolve, reject ) => {
|
package/src/s3.js
CHANGED
|
@@ -197,14 +197,13 @@ exports.get = async ( key, bucket = config?.s3?.Bucket, options = {} ) => {
|
|
|
197
197
|
* @description Sets an object in S3 with the provided key, body, and optional parameters.
|
|
198
198
|
*/
|
|
199
199
|
exports.set = async ( key, body, options = {} ) => {
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
} = options;
|
|
200
|
+
const bucket = options.bucket || config?.s3?.Bucket;
|
|
201
|
+
const contentType = options.contentType || 'application/json';
|
|
202
|
+
const cacheControl = options.cacheControl || 'max-age=25,s-maxage=30,must-revalidate';
|
|
203
|
+
const encrypt = Boolean ( options.encrypt );
|
|
204
|
+
const metadata = options.metadata || {};
|
|
205
|
+
const hasAcl = Object.prototype.hasOwnProperty.call ( options, 'acl' );
|
|
206
|
+
const acl = hasAcl ? options.acl : 'public-read';
|
|
208
207
|
|
|
209
208
|
if ( encrypt && ( contentType === 'application/json' || contentType === 'text/plain' ) ) {
|
|
210
209
|
|
|
@@ -234,16 +233,21 @@ exports.set = async ( key, body, options = {} ) => {
|
|
|
234
233
|
}
|
|
235
234
|
|
|
236
235
|
try {
|
|
237
|
-
const
|
|
236
|
+
const params = {
|
|
238
237
|
Bucket: bucket,
|
|
239
238
|
Key: key,
|
|
240
239
|
Body: body,
|
|
241
240
|
ContentType: contentType,
|
|
242
|
-
ACL: acl,
|
|
243
241
|
CacheControl: cacheControl,
|
|
244
242
|
Metadata: metadata,
|
|
245
243
|
ContentLength: Buffer.byteLength ( body )
|
|
246
|
-
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
if ( acl !== null && acl !== undefined && acl !== false ) {
|
|
247
|
+
params.ACL = acl;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const command = new PutObjectCommand ( params );
|
|
247
251
|
|
|
248
252
|
const data = await S3.send ( command );
|
|
249
253
|
|
|
@@ -408,4 +412,4 @@ const streamToBuffer = async ( stream ) => {
|
|
|
408
412
|
await pipelineAsync ( stream, collectorStream );
|
|
409
413
|
|
|
410
414
|
return Buffer.concat ( chunks );
|
|
411
|
-
};
|
|
415
|
+
};
|