lambda-toolkit 0.0.7-beta → 0.0.9-beta

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.
Files changed (2) hide show
  1. package/dist/index.js +60 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1446,6 +1446,7 @@ const aws = __webpack_require__( 4870 );
1446
1446
  const epoch = __webpack_require__( 3830 );
1447
1447
  const math = __webpack_require__( 943 );
1448
1448
  const object = __webpack_require__( 5762 );
1449
+ const redis = __webpack_require__( 4528 );
1449
1450
  const string = __webpack_require__( 268 );
1450
1451
  const utils = __webpack_require__( 6878 );
1451
1452
 
@@ -1456,6 +1457,7 @@ module.exports = {
1456
1457
  LambdaApi,
1457
1458
  math,
1458
1459
  object,
1460
+ redis,
1459
1461
  string,
1460
1462
  utils
1461
1463
  };
@@ -2129,11 +2131,13 @@ module.exports = ( obj, props ) => Object.fromEntries( Object.entries( obj ).fil
2129
2131
 
2130
2132
  const camelize = __webpack_require__( 8256 );
2131
2133
  const filterProps = __webpack_require__( 6451 );
2134
+ const removeEmptyArrays = __webpack_require__( 2047 );
2132
2135
  const snakelize = __webpack_require__( 7572 );
2133
2136
 
2134
2137
  module.exports = {
2135
2138
  camelize,
2136
2139
  filterProps,
2140
+ removeEmptyArrays,
2137
2141
  snakelize
2138
2142
  };
2139
2143
 
@@ -2152,6 +2156,14 @@ module.exports = obj =>
2152
2156
  !( obj instanceof Date );
2153
2157
 
2154
2158
 
2159
+ /***/ }),
2160
+
2161
+ /***/ 2047:
2162
+ /***/ ((module) => {
2163
+
2164
+ module.exports = o => Object.fromEntries( Object.entries( o ).filter( ( [ , v ] ) => !Array.isArray( v ) || v.length > 0 ) );
2165
+
2166
+
2155
2167
  /***/ }),
2156
2168
 
2157
2169
  /***/ 7572:
@@ -2170,6 +2182,54 @@ const change = ( obj, keepAllCaps ) =>
2170
2182
  module.exports = ( obj, { keepAllCaps = false } = {} ) => change( obj, keepAllCaps );
2171
2183
 
2172
2184
 
2185
+ /***/ }),
2186
+
2187
+ /***/ 5422:
2188
+ /***/ ((module) => {
2189
+
2190
+ global.__redisInstances = {};
2191
+
2192
+ /**
2193
+ * Create a redis client instance
2194
+ * @param {Object} redis Redis npm dependency
2195
+ * @param {String} address Redis DB address (either RW or RO)
2196
+ * @returns redisClient A new redis client instance connected to the database
2197
+ */
2198
+ module.exports = async ( { redis, address, protocol = 'rediss', port = 6379 } ) => {
2199
+ if ( global.__redisInstances[address] ) {
2200
+ try {
2201
+ const r = await global.__redisInstances[address].ping();
2202
+ if ( r === 'PONG' ) {
2203
+ return global.__redisInstances[address];
2204
+ } else {
2205
+ delete global.__redisInstances[address];
2206
+ }
2207
+ } catch {
2208
+ delete global.__redisInstances[address];
2209
+ }
2210
+ }
2211
+
2212
+ const client = redis.createClient( { url: `${protocol}://${address}:${port}`, socket: { keepAlive: 15000 } } );
2213
+
2214
+ await client.connect();
2215
+
2216
+ global.__redisInstances[address] = client;
2217
+ return client;
2218
+ };
2219
+
2220
+
2221
+ /***/ }),
2222
+
2223
+ /***/ 4528:
2224
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2225
+
2226
+ const createClient = __webpack_require__( 5422 );
2227
+
2228
+ module.exports = {
2229
+ createClient
2230
+ };
2231
+
2232
+
2173
2233
  /***/ }),
2174
2234
 
2175
2235
  /***/ 3914:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-toolkit",
3
- "version": "0.0.7-beta",
3
+ "version": "0.0.9-beta",
4
4
  "description": "A set of tools to help and simplify Node Js code development for AWS Lambdas",
5
5
  "files": [
6
6
  "./license",