@63klabs/cache-data 1.3.5 → 1.3.7
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 +49 -2
- package/CONTRIBUTING.md +167 -0
- package/README.md +139 -27
- package/package.json +13 -5
- package/src/lib/dao-cache.js +1418 -294
- package/src/lib/dao-endpoint.js +165 -41
- package/src/lib/tools/AWS.classes.js +82 -0
- package/src/lib/tools/CachedParametersSecrets.classes.js +98 -7
- package/src/lib/tools/ClientRequest.class.js +43 -10
- package/src/lib/tools/Connections.classes.js +148 -13
- package/src/lib/tools/DebugAndLog.class.js +244 -75
- package/src/lib/tools/ImmutableObject.class.js +44 -2
- package/src/lib/tools/RequestInfo.class.js +38 -0
- package/src/lib/tools/Response.class.js +245 -81
- package/src/lib/tools/ResponseDataModel.class.js +123 -47
- package/src/lib/tools/Timer.class.js +138 -26
- package/src/lib/tools/index.js +89 -2
- package/src/lib/tools/utils.js +40 -4
- package/src/lib/utils/InMemoryCache.js +221 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> **Note:** This project is still in beta. While every effort is made to prevent breaking changes, they may still occur. If after upgrading to a new version you experience any issue, please report the issue and go back to a previous version until a fix is released.
|
|
6
|
+
|
|
7
|
+
To report an issue, or to see proposed and upcoming enhancements, check out [63Klabs/cache-data Issues](https://github.com/63Klabs/cache-data/issues) page on GitHub.
|
|
6
8
|
|
|
7
9
|
Report all vulnerabilities under the [Security menu](https://github.com/63Klabs/cache-data/security/advisories) in the Cache-Data GitHub repository.
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## v1.3.8 (unreleased)
|
|
12
|
+
|
|
13
|
+
- Nothing yet
|
|
14
|
+
|
|
15
|
+
## v1.3.7 (2026-02-06)
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- **Cache DAO Undefined Header Bug** [Spec: 1-3-7-cache-dao-fix](.kiro/specs/1-3-7-cache-dao-fix/) - Fixed production bug where undefined values were passed to HTTP headers, causing request failures with "Invalid value 'undefined' for header" errors
|
|
19
|
+
- Cache.getHeader() now normalizes undefined to null for consistent behavior
|
|
20
|
+
- Added defensive validation at header assignment points in CacheableDataAccess.getData()
|
|
21
|
+
- Added Cache._isValidHeaderValue() helper method for header validation
|
|
22
|
+
- **Most likely cause:** The move from over-use of JSON Stringify/parse cycles in favor of cloning in v1.3.6. JSON stringify/parse removed undefined values from objects, covering an underlying issue that is now fixed.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- **Jest Testing Framework** [Spec: 1-3-7-cache-dao-fix](.kiro/specs/1-3-7-cache-dao-fix/) - Set up Jest alongside Mocha for better AWS integration testing
|
|
26
|
+
- Configured Jest with ES module support
|
|
27
|
+
- Added npm scripts: `test:jest`, `test:all`, `test:cache:jest`
|
|
28
|
+
- Jest tests use `*.jest.mjs` pattern to avoid conflicts with Mocha tests
|
|
29
|
+
|
|
30
|
+
## v1.3.6 (2025-02-02)
|
|
31
|
+
|
|
32
|
+
### Enhancement
|
|
33
|
+
|
|
34
|
+
- Added in-memory cache option for `Cache`. Even though concurrent functions will not be able to make use of another function's in memory cache, it will improve response time and lessen calls to DynamoDb.
|
|
35
|
+
- Documentation has been enhanced and expanded
|
|
36
|
+
- Added override for `"fast-xml-parser": ">=5.3.4"` to ensure no vulnerabilities during `npm install`.
|
|
37
|
+
- Reduced internal use of JSON.parse() and JSON.stringify() to improve speed (1-2x improvement)
|
|
38
|
+
- New `Config.getConnCacheProfile("myConnection", "myProfile")` method to get both `conn` and `cacheProfile` in one line rather than 3
|
|
39
|
+
- New `Config.getConn("myConnection")` to get the connection object directly in one line rather than 2
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
// OLD: Config.getConnection('name') object in 2 lines:
|
|
43
|
+
const connection = Config.getConnection('myConnection');
|
|
44
|
+
const conn = connection.toObject();
|
|
45
|
+
|
|
46
|
+
// NEW: Config.getConn('name') in 1 line:
|
|
47
|
+
const conn = Config.getConn('myConnection');
|
|
48
|
+
|
|
49
|
+
// OLD: Get connection object and cache profile in 3 lines:
|
|
50
|
+
const connection = Config.getConnection('myConnection');
|
|
51
|
+
const conn = connection.toObject();
|
|
52
|
+
const cacheProfile = connection.getCacheProfile();
|
|
53
|
+
|
|
54
|
+
// NEW: Get connection object and cache profile in 1 line:
|
|
55
|
+
const { conn, cacheProfile } = Config.getConnCacheProfile('myConnection', 'myProfile');
|
|
56
|
+
```
|
|
10
57
|
|
|
11
58
|
## v1.3.5 (2025-01-13)
|
|
12
59
|
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Contributions to this project are welcome! Whether you're fixing a bug, adding a new feature, or improving documentation, your help is appreciated.
|
|
4
|
+
|
|
5
|
+
Building a reputation will require a multi-step approach.
|
|
6
|
+
|
|
7
|
+
## Steps to Contributing
|
|
8
|
+
|
|
9
|
+
Begin by submitting bugs to ensure the project works for everyone. If you can submit code suggestions or pseudo code that helps! You can also examine a bug reported by someone else and provide helpful solutions to the team.
|
|
10
|
+
|
|
11
|
+
Submit feature requests. To keep this project simple and maintainable we accept features that are generally useful by an overwhelming majority of developers using the project. If you can submit code suggestions or pseudo code that helps! You can also examine a feature request from someone else and provide helpful solutions to the team.
|
|
12
|
+
|
|
13
|
+
After you have successfully participated in the bug reporting and feature request process, fork the repository and make your changes in a separate branch. Once you're satisfied with your changes, submit a pull request for review. Please only submit small changes (a single feature) at first. Pull requests with major code updates or frequent pull requests will often get ignored. Changes should also have code and testing methods well documented.
|
|
14
|
+
|
|
15
|
+
All code changes MUST start as an Issue (or security report) with a clear description of the problem or enhancement. No changes should be submitted to the repository without an attached, and approved, Issue.
|
|
16
|
+
|
|
17
|
+
Code developed (by AI or Human) outside of Kiro (see below) must NOT be submitted directly to the repository. Instead submit a proof of concept for a new piece of code or method via the Issue tracker as an enhancement. Someone from the team will review, evaluate the usefulness, and then implement using the proper process.
|
|
18
|
+
|
|
19
|
+
## Use of AI
|
|
20
|
+
|
|
21
|
+
This project utilizes the Spec-Driven, AI-Assisted Engineering approach.
|
|
22
|
+
|
|
23
|
+
Spec-Driven, AI-Assisted Engineering (SD-AI) is a software development methodology that prioritizes creating detailed, structured specifications before writing code. It priortizes context, requirements, and architectural constraints to generate accurate, non-hallucinated code. This approach shifts from ad-hoc, prompt-driven "vibe coding" to a structured, human-guided, AI-executed workflow, improving reliability in complex projects.
|
|
24
|
+
|
|
25
|
+
> Contributors are responsible for every line of code--AI-generated or not.
|
|
26
|
+
|
|
27
|
+
Code must be reviewed, understood, and tested by a human before being merged.
|
|
28
|
+
|
|
29
|
+
Kiro is the required AI coding assistant for final integrations, documentation, and testing, as it is in the AWS Ecosystem and this project is deveoped to deploy on the AWS platform. Just like test suites, Kiro ensures the proper tests, documentation, and guardrails are in place. Kiro is as important as commit-hooks and tests as it is a tool that ensures quality checks and should not be bypassed.
|
|
30
|
+
|
|
31
|
+
Ensure [AI Context](./AI_CONTEXT.md) and [Kiro steering documents](.kiro/steering/ai-context-reference.md) are reviewed, understood, and used by both humans and AI.
|
|
32
|
+
|
|
33
|
+
## Development Setup
|
|
34
|
+
|
|
35
|
+
Tests and documentation are critical to this project.
|
|
36
|
+
|
|
37
|
+
Do not disable tests.
|
|
38
|
+
Do not change tests.
|
|
39
|
+
Do not break the build.
|
|
40
|
+
|
|
41
|
+
Before contributing code, set up your development environment:
|
|
42
|
+
|
|
43
|
+
### Quick Setup (Recommended)
|
|
44
|
+
|
|
45
|
+
Run the automated setup script:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/63klabs/cache-data.git
|
|
49
|
+
cd cache-data
|
|
50
|
+
./scripts/setup-dev-environment.sh
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This script will:
|
|
54
|
+
- Install npm dependencies
|
|
55
|
+
- Configure the pre-commit hook
|
|
56
|
+
- Run validation tests
|
|
57
|
+
- Display helpful next steps
|
|
58
|
+
|
|
59
|
+
### Manual Setup
|
|
60
|
+
|
|
61
|
+
If you prefer to set up manually:
|
|
62
|
+
|
|
63
|
+
### 1. Clone and Install Dependencies
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git clone https://github.com/63klabs/cache-data.git
|
|
67
|
+
cd cache-data
|
|
68
|
+
npm install
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 2. Install Pre-Commit Hook
|
|
72
|
+
|
|
73
|
+
The project includes a pre-commit hook that validates documentation quality before allowing commits. This ensures all contributions maintain documentation standards.
|
|
74
|
+
|
|
75
|
+
**Install the hook:**
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# The hook is already in .git/hooks/pre-commit
|
|
79
|
+
# Make sure it's executable
|
|
80
|
+
chmod +x .git/hooks/pre-commit
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**What the hook validates:**
|
|
84
|
+
- ✅ JSDoc completeness (all required tags present)
|
|
85
|
+
- ✅ JSDoc accuracy (parameters match function signatures)
|
|
86
|
+
- ✅ Documentation links are valid
|
|
87
|
+
- ✅ Code examples have valid syntax
|
|
88
|
+
|
|
89
|
+
**The hook will block commits if:**
|
|
90
|
+
- Incomplete JSDoc (missing @param, @returns, @example tags)
|
|
91
|
+
- Inaccurate JSDoc (parameter names don't match code)
|
|
92
|
+
- Broken links in documentation files
|
|
93
|
+
- Invalid syntax in code examples
|
|
94
|
+
|
|
95
|
+
**Note**: The hook reports "Missing JSDoc" items for informational purposes, but these don't block commits due to known parser limitations. Only the issues listed above will prevent commits.
|
|
96
|
+
|
|
97
|
+
**Test the hook:**
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Run the validation manually
|
|
101
|
+
.git/hooks/pre-commit
|
|
102
|
+
|
|
103
|
+
# Expected output:
|
|
104
|
+
# ✅ All validation checks passed
|
|
105
|
+
# ✅ Documentation validation passed!
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**If validation fails:**
|
|
109
|
+
1. Review the error messages - they indicate specific files and issues
|
|
110
|
+
2. Fix the documentation issues identified
|
|
111
|
+
3. Run the hook again to verify fixes
|
|
112
|
+
4. Only use `git commit --no-verify` if you're certain the errors are false positives
|
|
113
|
+
|
|
114
|
+
### 3. Run Tests
|
|
115
|
+
|
|
116
|
+
Ensure all tests pass before submitting changes:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Run all tests
|
|
120
|
+
npm test
|
|
121
|
+
|
|
122
|
+
# Run specific test suites
|
|
123
|
+
npm test -- test/documentation/
|
|
124
|
+
npm test -- test/cache/
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Documentation Standards
|
|
128
|
+
|
|
129
|
+
All public APIs must have complete JSDoc documentation. See [Documentation Standards](.kiro/steering/documentation-standards.md) for detailed requirements.
|
|
130
|
+
|
|
131
|
+
**Required JSDoc tags:**
|
|
132
|
+
- Description of what the function/class does
|
|
133
|
+
- `@param` for each parameter with type and description
|
|
134
|
+
- `@returns` with type and description (omit for void functions)
|
|
135
|
+
- `@example` with at least one working code example
|
|
136
|
+
- `@throws` for each error type that can be thrown
|
|
137
|
+
|
|
138
|
+
**Example:**
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
/**
|
|
142
|
+
* Retrieves cached data or fetches from source if not cached
|
|
143
|
+
*
|
|
144
|
+
* @param {object} cacheProfile - Cache configuration profile
|
|
145
|
+
* @param {Function} fetchFunction - Function to fetch data if not cached
|
|
146
|
+
* @param {object} connection - Connection configuration
|
|
147
|
+
* @returns {Promise<{success: boolean, data: object, cached: boolean}>} Result object with data and cache status
|
|
148
|
+
* @throws {Error} If cache profile is invalid
|
|
149
|
+
* @example
|
|
150
|
+
* const result = await CacheableDataAccess.getData(
|
|
151
|
+
* cacheProfile,
|
|
152
|
+
* endpoint.get,
|
|
153
|
+
* connection
|
|
154
|
+
* );
|
|
155
|
+
* console.log(result.data);
|
|
156
|
+
*/
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Current Contributors
|
|
160
|
+
|
|
161
|
+
Thank you to the following people who have contributed to this project:
|
|
162
|
+
|
|
163
|
+
Chad Kluck\
|
|
164
|
+
DevOps & Developer Experience Engineer\
|
|
165
|
+
AWS Certified Cloud Practitioner | AWS Certified Developer - Associate | AWS
|
|
166
|
+
Certified Solutions Architect - Associate\
|
|
167
|
+
[Website](https://chadkluck.me)
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ A package for AWS Lambda Node.js applications to access and cache data from remo
|
|
|
5
5
|
> Note: This repository and package has moved from chadkluck to 63Klabs but is still managed by the same developer.
|
|
6
6
|
|
|
7
7
|
- [@63klabs/cache-data on npmjs.com](https://www.npmjs.com/package/@63klabs/cache-data)
|
|
8
|
-
- [@63klabs/cache-data on GitHub](https://github.com
|
|
8
|
+
- [@63klabs/cache-data on GitHub](https://github.com/63Klabs/cache-data)
|
|
9
9
|
|
|
10
10
|
## Description
|
|
11
11
|
|
|
@@ -17,19 +17,55 @@ It can be used in place of Express.js for simple web service applications as it
|
|
|
17
17
|
|
|
18
18
|
This package has been used in production environments for web service applications receiving over 1 million requests per week with a 75% cache-hit rate lowering latency to less than 100ms in most cases. This is a considerable improvement when faced with resource intense processes, connection pools, API rate limits, and slow endpoints.
|
|
19
19
|
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
The @63klabs/cache-data package provides three main modules:
|
|
23
|
+
|
|
24
|
+
### Cache Module
|
|
25
|
+
- **Distributed Caching**: Share cached data across concurrent Lambda executions using DynamoDb and S3
|
|
26
|
+
- **In-Memory Cache**: Optional in-memory caching layer for improved response times within a single execution
|
|
27
|
+
- **Flexible Storage**: Automatic storage selection based on data size (DynamoDb for small items, S3 for large items)
|
|
28
|
+
- **Data Encryption**: Secure your cached data with encryption keys stored in SSM Parameter Store
|
|
29
|
+
- **Cache Profiles**: Configure multiple cache profiles with different expiration policies
|
|
30
|
+
|
|
31
|
+
### Endpoint Module
|
|
32
|
+
- **HTTP/HTTPS Requests**: Make requests to external APIs and endpoints with built-in retry logic
|
|
33
|
+
- **Connection Management**: Define and manage multiple endpoint connections with authentication
|
|
34
|
+
- **Request Caching**: Automatically cache endpoint responses to reduce API calls and improve performance
|
|
35
|
+
- **Flexible Configuration**: Support for custom headers, query parameters, request bodies, and timeouts
|
|
36
|
+
|
|
37
|
+
### Tools Module
|
|
38
|
+
- **Logging and Debugging**: `DebugAndLog` class for structured logging with configurable log levels
|
|
39
|
+
- **Performance Timing**: `Timer` class for measuring execution time and performance metrics
|
|
40
|
+
- **Request Handling**: `ClientRequest` and `Response` classes for building web service applications
|
|
41
|
+
- **AWS Integration**: Direct access to AWS SDK v3 for DynamoDb, S3, and SSM Parameter Store
|
|
42
|
+
- **Parameter and Secret Caching**: `CachedParameterSecrets` classes for AWS Parameters and Secrets Lambda Extension
|
|
43
|
+
- **Utility Functions**: Data sanitization, obfuscation, hashing, and immutable object creation
|
|
44
|
+
- **Response Generators**: Built-in generators for JSON, HTML, XML, RSS, and text responses
|
|
45
|
+
|
|
20
46
|
## Getting Started
|
|
21
47
|
|
|
22
48
|
### Requirements
|
|
23
49
|
|
|
24
|
-
- Node
|
|
25
|
-
- AWS
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
50
|
+
- Node.js >=20.0.0 runtime on Lambda
|
|
51
|
+
- AWS Services:
|
|
52
|
+
- **AWS Lambda**: For running your serverless functions
|
|
53
|
+
- **Amazon S3**: For storing large cached objects
|
|
54
|
+
- **Amazon DynamoDB**: For storing cache metadata and small cached objects
|
|
55
|
+
- **AWS Systems Manager (SSM) Parameter Store**: For storing configuration and encryption keys
|
|
56
|
+
- A basic understanding of CloudFormation, Lambda, S3, DynamoDB, and SSM Parameters
|
|
57
|
+
- A basic understanding of IAM policies, especially the Lambda Execution Role, that will allow Lambda to access S3, DynamoDB, and SSM Parameter Store
|
|
58
|
+
- Lambda function should have between 512MB and 2048MB of memory allocated (>1024MB recommended). See [Lambda Optimization: Memory Allocation](./docs/lambda-optimization/README.md#lambda-memory-allocation)
|
|
29
59
|
|
|
30
60
|
### Installing
|
|
31
61
|
|
|
32
|
-
|
|
62
|
+
Install the package using npm:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm install @63klabs/cache-data
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The simplest way to get started is to use the [63klabs Atlantis Templates and Script platform](https://github.com/63Klabs/atlantis-cfn-configuration-repo-for-serverless-deployments) to deploy this and other ready-to-run solutions via CI/CD.
|
|
33
69
|
|
|
34
70
|
However, if you want to write your own templates and code, follow the following steps:
|
|
35
71
|
|
|
@@ -37,15 +73,17 @@ However, if you want to write your own templates and code, follow the following
|
|
|
37
73
|
- Use the [key generation script](./docs/00-example-implementation/generate-put-ssm.py) during [the build](./docs/00-example-implementation/example-buildspec.yml) to establish a key to encrypt your data.
|
|
38
74
|
2. Lambda CloudFormation Template:
|
|
39
75
|
- See [Lambda template example](./docs/00-example-implementation/example-template-lambda-function.yml)
|
|
40
|
-
- Node: AWS Lambda supported version of Node
|
|
41
|
-
- Memory: Allocate at least
|
|
76
|
+
- Node: AWS Lambda supported version of Node (>=20.0.0)
|
|
77
|
+
- Memory: Allocate at least 512MB (1024MB+ recommended)
|
|
42
78
|
- Environment Variables: Add the cache-data environment variables to your Lambda function.
|
|
43
|
-
- Execution Role: Include access to S3 and
|
|
44
|
-
3. S3 and
|
|
45
|
-
- See [S3 and
|
|
79
|
+
- Execution Role: Include access to S3 and DynamoDB in your Lambda's execution role.
|
|
80
|
+
3. S3 and DynamoDB CloudFormation Template to store your cache:
|
|
81
|
+
- See [S3 and DynamoDB Cache Store template example](./docs/00-example-implementation/example-template-s3-and-dynamodb-cache-store.yml)
|
|
46
82
|
- Include in your application infrastructure template or as separate infrastructure.
|
|
47
83
|
4. Install the @63klabs/cache-data package:
|
|
48
|
-
|
|
84
|
+
```bash
|
|
85
|
+
npm install @63klabs/cache-data
|
|
86
|
+
```
|
|
49
87
|
5. Add code to your Lambda function to utilize caching and other cache-data utilities:
|
|
50
88
|
- See [example code for index and handler](./docs/00-example-implementation/example-handler.js)
|
|
51
89
|
- See [example code for config initialization](./docs/00-example-implementation/example-config.js)
|
|
@@ -56,6 +94,68 @@ It is recommended that you use the quick-start method when implementing for the
|
|
|
56
94
|
- [Advanced Implementation for Providing a Web Service](./docs/01-advanced-implementation-for-web-service/README.md)
|
|
57
95
|
- [Additional Documentation](./docs/README.md)
|
|
58
96
|
|
|
97
|
+
## Quick Start Examples
|
|
98
|
+
|
|
99
|
+
### Basic Caching Example
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
const { cache } = require("@63klabs/cache-data");
|
|
103
|
+
|
|
104
|
+
// Initialize cache with your S3 bucket and DynamoDB table
|
|
105
|
+
cache.Cache.init({
|
|
106
|
+
s3Bucket: process.env.CACHE_DATA_S3_BUCKET,
|
|
107
|
+
dynamoDbTable: process.env.CACHE_DATA_DYNAMODB_TABLE,
|
|
108
|
+
securityKey: process.env.CACHE_DATA_SECURITY_KEY
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Cache some data
|
|
112
|
+
const cacheKey = "my-data-key";
|
|
113
|
+
const dataToCache = { message: "Hello, World!", timestamp: Date.now() };
|
|
114
|
+
|
|
115
|
+
await cache.Cache.put(cacheKey, dataToCache, 3600); // Cache for 1 hour
|
|
116
|
+
|
|
117
|
+
// Retrieve cached data
|
|
118
|
+
const cachedData = await cache.Cache.get(cacheKey);
|
|
119
|
+
if (cachedData) {
|
|
120
|
+
console.log("Retrieved from cache:", cachedData);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Making Endpoint Requests
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
const { endpoint } = require("@63klabs/cache-data");
|
|
128
|
+
|
|
129
|
+
// Make a simple GET request to an API
|
|
130
|
+
const response = await endpoint.get(
|
|
131
|
+
{ host: "api.example.com", path: "/data" },
|
|
132
|
+
{ parameters: { q: "search-term" } }
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
console.log("API Response:", response.body);
|
|
136
|
+
console.log("Status Code:", response.statusCode);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Using Utility Tools
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
const { tools } = require("@63klabs/cache-data");
|
|
143
|
+
|
|
144
|
+
// Create a timer to measure performance
|
|
145
|
+
const timer = new tools.Timer("my-operation");
|
|
146
|
+
timer.start();
|
|
147
|
+
|
|
148
|
+
// Your code here...
|
|
149
|
+
|
|
150
|
+
timer.stop();
|
|
151
|
+
console.log(`Operation took ${timer.elapsed()}ms`);
|
|
152
|
+
|
|
153
|
+
// Use the logger
|
|
154
|
+
const logger = new tools.DebugAndLog("MyApp");
|
|
155
|
+
logger.info("Application started");
|
|
156
|
+
logger.error("An error occurred", { details: "error info" });
|
|
157
|
+
```
|
|
158
|
+
|
|
59
159
|
## Help
|
|
60
160
|
|
|
61
161
|
Make sure you have your S3 bucket, DynamoDb table, and SSM Parameter store set up. Also make sure that you have IAM policies to allow your Lambda function access to these, and CodeBuild to read and write to SSM Parameter store.
|
|
@@ -64,30 +164,42 @@ Review the [Documentation](./docs/README.md) which includes implementation guide
|
|
|
64
164
|
|
|
65
165
|
A full implementation example and tutorial is provided as one of the Atlantis Application Starters available through the [Atlantis Tutorials repository](https://github.com/63klabs/atlantis-tutorials). (Atlantis is a collection of templates and deployment scripts to assist in starting and automating serverless deployments using AWS SAM and CloudFormation.)
|
|
66
166
|
|
|
67
|
-
##
|
|
167
|
+
## Tutorials
|
|
168
|
+
|
|
169
|
+
Read the [Atlantis Tutorials introductory page](https://github.com/63Klabs/atlantis-tutorials) for overall usage of Atlantis Platform Templates and Scripts.
|
|
170
|
+
|
|
171
|
+
## License
|
|
68
172
|
|
|
69
|
-
|
|
173
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE.txt) file for details.
|
|
70
174
|
|
|
71
175
|
## Change Log
|
|
72
176
|
|
|
73
|
-
See [Change Log](CHANGELOG.md) for version history and changes.
|
|
177
|
+
See [Change Log](./CHANGELOG.md) for version history and changes.
|
|
74
178
|
|
|
75
179
|
## Issues, Features, and Enhancements
|
|
76
180
|
|
|
77
181
|
Visit the [Issues section of the @63Klabs Cache-Data GitHub repository](https://github.com/63Klabs/cache-data/issues) for information on reported issues, upcoming fixes and enhancements, and to submit requests.
|
|
78
182
|
|
|
79
|
-
##
|
|
183
|
+
## Security
|
|
184
|
+
|
|
185
|
+
If you discover any security related issues, please see the [SECURITY](SECURITY.md) file for details.
|
|
186
|
+
|
|
187
|
+
## Contributing
|
|
188
|
+
|
|
189
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
|
|
190
|
+
|
|
191
|
+
**For Contributors**: After cloning the repository, run the setup script to configure your development environment:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
./scripts/setup-dev-environment.sh
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
This will install dependencies, configure the pre-commit hook for documentation validation, and run tests to ensure everything is working correctly.
|
|
80
198
|
|
|
81
|
-
|
|
199
|
+
## AI Context
|
|
82
200
|
|
|
83
|
-
|
|
201
|
+
See [AI_CONTEXT.md](AI_CONTEXT.md) for important context and guidelines for AI-generated code in this repository.
|
|
84
202
|
|
|
85
|
-
|
|
203
|
+
The context file is also helpful (and perhaps essential) for HUMANS developing within the application's structured platform as well.
|
|
86
204
|
|
|
87
|
-
-
|
|
88
|
-
- [AWS Certified Developer - Associate](https://www.credly.com/users/chad-kluck/badges)
|
|
89
|
-
- [Website: chadkluck.me](https://chadkluck.me/)
|
|
90
|
-
- [GitHub: chadkluck](https://github.com/chadkluck)
|
|
91
|
-
- [GitHub: 63Klabs](https://github.com/63klabs)
|
|
92
|
-
- [Mastodon: @chadkluck@universeodon.com](https://universeodon.com/@chadkluck)
|
|
93
|
-
- [LinkedIn](https://www.linkedin.com/in/chadkluck/)
|
|
205
|
+
AI Assisted Engineering of this solution was provided by [Kiro](https://kiro.dev/). Steering documents are provided in the repository's [.kiro](.kiro/steering/ai-context-reference.md) directory. Because testing is tightly coupled with the implementation, it is suggested all documents, code, and tests are thoroughly reviewed before, and updated after, any changes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@63klabs/cache-data",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
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",
|
|
@@ -25,14 +25,22 @@
|
|
|
25
25
|
"@aws-sdk/client-s3": "3.x",
|
|
26
26
|
"@aws-sdk/client-ssm": "3.x",
|
|
27
27
|
"@aws-sdk/lib-dynamodb": "3.x",
|
|
28
|
-
"chai": "^6.
|
|
29
|
-
"chai-http": "^5.
|
|
30
|
-
"
|
|
31
|
-
"
|
|
28
|
+
"chai": "^6.x",
|
|
29
|
+
"chai-http": "^5.x",
|
|
30
|
+
"fast-check": "^4.x",
|
|
31
|
+
"jest": "^30.2.0",
|
|
32
|
+
"mocha": "^11.x",
|
|
33
|
+
"sinon": "^21.x"
|
|
34
|
+
},
|
|
35
|
+
"overrides": {
|
|
36
|
+
"fast-xml-parser": ">=5.3.4"
|
|
32
37
|
},
|
|
33
38
|
"scripts": {
|
|
34
39
|
"test": "mocha 'test/**/*-tests.mjs'",
|
|
40
|
+
"test:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
41
|
+
"test:all": "npm test && npm run test:jest",
|
|
35
42
|
"test:cache": "mocha 'test/cache/**/*-tests.mjs'",
|
|
43
|
+
"test:cache:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js test/cache",
|
|
36
44
|
"test:config": "mocha 'test/config/**/*-tests.mjs'",
|
|
37
45
|
"test:endpoint": "mocha 'test/endpoint/**/*-tests.mjs'",
|
|
38
46
|
"test:logging": "mocha 'test/logging/**/*-tests.mjs'",
|