@63klabs/cache-data 1.2.3 → 1.2.5

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/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  > Note: This project is still in beta. Even though changes are tested and breaking changes are avoided, things may break. The latest 1.1.x version is stable.
6
6
 
7
+ ## 1.2.5 (2025-06-23)
8
+
9
+ - Updated suggested Lambda environment variables to uppercase: `CACHE_DATA_`
10
+ - Added check for environment variable `DEPLOY_ENVIRONMENT` among current list of variables checked to determine environment.
11
+
7
12
  ## 1.1.6 (2025-05-05) Moving to @63Klabs
8
13
 
9
14
  This package has come a long way and is stable. To enhance its longevity I am moving it out of my personal GitHub and NPM accounts an into an organizational account managed by me (chadkluck).
package/README.md CHANGED
@@ -81,21 +81,22 @@ Resources:
81
81
 
82
82
  Environment:
83
83
  Variables:
84
- detailedLogs: "5" # Use "0" for production
85
- deployEnvironment: "TEST" # "PROD"
86
- paramStore: "/" # SSM Parameter store can use a hierarchy to organize your apps parameters
84
+
85
+ NODE_ENV: !If [ IsProduction, "production", "development"] # Note we are past the build installation phase so devDependencies are not installed, however, we can utilize certain tools in development mode
86
+ DEPLOY_ENVIRONMENT: !Ref DeployEnvironment # PROD, TEST, DEV - a different category of environment
87
+ LOG_LEVEL: !If [ IsProduction, "0", "5"] # 0 for prod, 2-5 for non-prod
88
+ PARAM_STORE_PATH: "/" # SSM Parameter store can use a hierarchy to organize your apps parameters
87
89
 
88
90
  # Cache-Data settings (from: https://www.npmjs.com/package/@63klabs/cache-data)
89
- CacheData_DynamoDbTable: !Ref CacheDataDynamoDbTable
90
- CacheData_S3Bucket: !Ref CacheDataS3Bucket
91
- CacheData_CryptSecureDataAlgorithm: !Ref CacheDataCryptSecureDataAlg
92
- CacheData_CryptIdHashAlgorithm: !Ref CacheDataCryptIdHashAlgorithm
93
- CacheData_DynamoDb_maxCacheSize_kb: !Ref CacheDataDbMaxCacheSizeInKB
94
- CacheData_PurgeExpiredCacheEntriesAfterXHours: !Ref CacheDataPurgeExpiredCacheEntriesInHours
95
- CacheData_ErrorExpirationInSeconds: !Ref CacheDataErrorExpirationInSeconds
96
- CacheData_TimeZoneForInterval: !Ref CacheDataTimeZoneForInterval
97
- CacheData_AWSXRayOn: !Ref CacheDataAWSXRayOn
98
-
91
+ CACHE_DATA_DYNAMO_DB_TABLE: !Ref CacheDataDynamoDbTable
92
+ CACHE_DATA_S3_BUCKET: !Ref CacheDataS3Bucket
93
+ CACHE_DATA_SECURE_DATA_ALGORITHM: !Ref CacheDataCryptSecureDataAlg
94
+ CACHE_DATA_ID_HASH_ALGORITHM: !Ref CacheDataCryptIdHashAlgorithm
95
+ CACHE_DATA_DYNAMO_DB_MAX_CACHE_SIZE_KB: !Ref CacheDataDbMaxCacheSizeInKB
96
+ CACHE_DATA_PURGE_EXPIRED_CACHE_ENTRIES_AFTER_X_HRS: !Ref CacheDataPurgeExpiredCacheEntriesInHours
97
+ CACHE_DATA_ERROR_EXP_IN_SECONDS: !Ref CacheDataErrorExpirationInSeconds
98
+ CACHE_DATA_TIME_ZONE_FOR_INTERVAL: !Ref CacheDataTimeZoneForInterval
99
+ CACHE_DATA_AWS_X_RAY_ON: !Ref CacheDataAWSXRayOn
99
100
 
100
101
  # -- LambdaFunction Execution Role --
101
102
 
@@ -386,7 +387,7 @@ class Config extends tools._ConfigSuperClass {
386
387
  [
387
388
  {
388
389
  "group": "app", // so we can do params.app.weatherapikey later
389
- "path": process.env.paramStore
390
+ "path": process.env.PARAM_STORE_PATH
390
391
  }
391
392
  ]
392
393
  );
@@ -516,7 +517,7 @@ class Config extends tools._ConfigSuperClass {
516
517
  [
517
518
  {
518
519
  "group": "app", // so we can do params.app.weatherapikey later
519
- "path": "/apps/my_cool_app/" // process.env.paramStorePath // or store as a Lambda environment variable
520
+ "path": "/apps/my_cool_app/" // process.env.PARAM_STORE_PATH // or store as a Lambda environment variable
520
521
  }
521
522
  ]
522
523
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@63klabs/cache-data",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "Cache data from an API endpoint or application process using AWS S3 and DynamoDb",
5
5
  "author": "Chad Leigh Kluck (https://chadkluck.me)",
6
6
  "license": "MIT",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "aws-xray-sdk-core": "^3.6.0",
20
- "moment-timezone": "^0.5.43",
20
+ "moment-timezone": "^0.6.0",
21
21
  "object-hash": "^3.0.0"
22
22
  },
23
23
  "devDependencies": {
@@ -30,7 +30,7 @@
30
30
  "chai-http": "^5.1.1",
31
31
  "lambda-tester": "^4.0.1",
32
32
  "mocha": "^11.1.0",
33
- "sinon": "^20.0.0"
33
+ "sinon": "^21.0.0"
34
34
  },
35
35
  "scripts": {
36
36
  "test": "mocha 'test/**/*-tests.mjs'",
@@ -54,5 +54,5 @@
54
54
  "bugs": {
55
55
  "url": "https://github.com/63klabs/npm-cache-data/issues"
56
56
  },
57
- "homepage": "https://github.com/chadkluck/npm-chadkluck-cache-data#readme"
57
+ "homepage": "https://github.com/63klabs/npm-cache-data#readme"
58
58
  }
@@ -1054,14 +1054,14 @@ class Cache {
1054
1054
  * Sample param object:
1055
1055
  * @example
1056
1056
  * cache.Cache.init({
1057
- * dynamoDbTable: process.env.CacheData_DynamoDbTable,
1058
- * s3Bucket: process.env.CacheData_S3Bucket,
1059
- * secureDataAlgorithm: process.env.CacheData_CryptSecureDataAlgorithm,
1057
+ * dynamoDbTable: process.env.CACHE_DATA_DYNAMO_DB_TABLE,
1058
+ * s3Bucket: process.env.CACHE_DATA_S3_BUCKET,
1059
+ * secureDataAlgorithm: process.env.CACHE_DATA_SECURE_DATA_ALGORITHM,
1060
1060
  * secureDataKey: Buffer.from(params.app.crypt_secureDataKey, cache.Cache.CRYPT_ENCODING),
1061
- * idHashAlgorithm: process.env.CacheData_CryptIdHashAlgorithm,
1062
- * DynamoDbMaxCacheSize_kb: parseInt(process.env.CacheData_DynamoDb_maxCacheSize_kb, 10),
1063
- * purgeExpiredCacheEntriesAfterXHours: parseInt(process.env.CacheData_PurgeExpiredCacheEntriesAfterXHours, 10),
1064
- * timeZoneForInterval: process.env.CacheData_TimeZoneForInterval // if caching on interval, we need a timezone to account for calculating hours, days, and weeks. List: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
1061
+ * idHashAlgorithm: process.env.CACHE_DATA_ID_HASH_ALGORITHM, // sha1, sha256, sha512, etc.
1062
+ * DynamoDbMaxCacheSize_kb: parseInt(process.env.CACHE_DATA_DYNAMO_DB_MAX_CACHE_SIZE_KB, 10),
1063
+ * purgeExpiredCacheEntriesAfterXHours: parseInt(process.env.CACHE_DATA_PURGE_EXPIRED_CACHE_ENTRIES_AFTER_X_HRS, 10),
1064
+ * timeZoneForInterval: process.env.CACHE_DATA_TIME_ZONE_FOR_INTERVAL // if caching on interval, we need a timezone to account for calculating hours, days, and weeks. List: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
1065
1065
  * });
1066
1066
  *
1067
1067
  * @param {Object} parameters
@@ -104,8 +104,8 @@ class DebugAndLog {
104
104
  * @returns {string} The current environment.
105
105
  */
106
106
  static getEnv() {
107
- var possibleVars = ["env", "deployEnvironment", "environment", "stage"]; // this is the application env, not the NODE_ENV
108
- var env = DebugAndLog.PROD; // if env or deployEnvironment not set, fail to safe
107
+ var possibleVars = ["env", "deployEnvironment", "environment", "stage, deploy_environment"]; // this is the application env, not the NODE_ENV
108
+ var env = (process.env?.NODE_ENV === "development" ? DebugAndLog.DEV : DebugAndLog.PROD); // if env or deployEnvironment not set, fail to safe
109
109
 
110
110
  if ( "env" in process ) {
111
111
  for (let i in possibleVars) {
@@ -249,18 +249,18 @@ class _ConfigSuperClass {
249
249
  * let params = await this._initParameters(
250
250
  * [
251
251
  * {
252
- * "group": "appone", // so we can do params.app.authOSTActionsUsername later
253
- * "path": process.env.paramStorePath, // Lambda environment variable
252
+ * "group": "appone", // so we can do params.app.authUsername later
253
+ * "path": process.env.PARAM_STORE_PATH, // Lambda environment variable
254
254
  * "names": [
255
- * "authOSTActionsUsername",
256
- * "authOSTActionsPassword",
257
- * "authExLibrisAPIkey",
255
+ * "authUsername",
256
+ * "authPassword",
257
+ * "authAPIkey",
258
258
  * "crypt_secureDataKey"
259
259
  * ]
260
260
  * }, // OR get all under a single path
261
261
  * {
262
- * "group": "app", // so we can do params.app.authOSTActionsUsername later
263
- * "path": process.env.paramStorePath // Lambda environment variable
262
+ * "group": "app", // so we can do params.app.authUsername later
263
+ * "path": process.env.PARAM_STORE_PATH // Lambda environment variable
264
264
  * }
265
265
  * ]
266
266
  * );