Describe your use case
JavaScript/TypeScript developers need a simple, practical client example to integrate PowerMem's intelligent memory capabilities into their web applications or Node.js backends. This example will demonstrate how to interact with the PowerMem HTTP API Server using native fetch API or popular HTTP libraries, enabling JavaScript/TypeScript applications to leverage PowerMem's memory management features.
Describe the solution you'd like
Create a simple JavaScript/TypeScript client example that demonstrates:
-
Basic HTTP client setup:
- Configuration for API base URL and API key
- HTTP client initialization (using native
fetch or minimal library)
- Request/response handling with proper JSON serialization/deserialization
-
Core memory operations:
- Create memory (
POST /api/v1/memories)
- Search memories (
POST /api/v1/memories/search)
- List memories (
GET /api/v1/memories)
- Update memory (
PUT /api/v1/memories/{memory_id})
- Delete memory (
DELETE /api/v1/memories/{memory_id})
-
Project structure:
- Simple Node.js project structure
- TypeScript support (optional but recommended)
- Main example file demonstrating all operations
- PowerMem client class/module
- Type definitions for requests/responses
- Configuration management
- Error handling examples
-
Deliverables:
examples/javascript/ or examples/typescript/ directory with:
client.ts or client.js - PowerMem client class
example.ts or example.js - Main example demonstrating all operations
types.ts or types.d.ts - TypeScript type definitions (if using TS)
package.json - Node.js package configuration
tsconfig.json - TypeScript configuration (if using TS)
README.md - Usage instructions and examples
- Basic error handling
- Example output showing successful operations
- Support for both CommonJS and ES modules (optional)
The solution should:
- Use Node.js 18+ or modern browser with fetch support
- Minimize dependencies (prefer native
fetch, optionally add axios if needed)
- Follow JavaScript/TypeScript best practices and conventions
- Include clear comments and JSDoc/TSDoc
- Handle 64-bit integer IDs properly (memory_id as string to avoid precision loss)
- Support both JSON request/response handling
- Include example usage in README
- Work in both Node.js and browser environments (if possible)
Describe alternatives you've considered
- Using a full-featured HTTP client library - but we want to keep it simple and demonstrate core concepts
- Creating a complete SDK - but that's too complex for a 2-hour coding session
Additional context
- The PowerMem HTTP API Server is already available and documented at
docs/api/0005-api_server.md
- Base URL:
http://localhost:8000/api/v1
- API Key authentication via
X-API-Key header
- All endpoints return JSON responses
- Memory IDs are 64-bit integers that should be handled as strings in JSON to avoid precision loss (see
docs/guides/1000-other_notes.md)
- The example should demonstrate async/await patterns
Describe your use case
JavaScript/TypeScript developers need a simple, practical client example to integrate PowerMem's intelligent memory capabilities into their web applications or Node.js backends. This example will demonstrate how to interact with the PowerMem HTTP API Server using native
fetchAPI or popular HTTP libraries, enabling JavaScript/TypeScript applications to leverage PowerMem's memory management features.Describe the solution you'd like
Create a simple JavaScript/TypeScript client example that demonstrates:
Basic HTTP client setup:
fetchor minimal library)Core memory operations:
POST /api/v1/memories)POST /api/v1/memories/search)GET /api/v1/memories)PUT /api/v1/memories/{memory_id})DELETE /api/v1/memories/{memory_id})Project structure:
Deliverables:
examples/javascript/orexamples/typescript/directory with:client.tsorclient.js- PowerMem client classexample.tsorexample.js- Main example demonstrating all operationstypes.tsortypes.d.ts- TypeScript type definitions (if using TS)package.json- Node.js package configurationtsconfig.json- TypeScript configuration (if using TS)README.md- Usage instructions and examplesThe solution should:
fetch, optionally addaxiosif needed)Describe alternatives you've considered
Additional context
docs/api/0005-api_server.mdhttp://localhost:8000/api/v1X-API-Keyheaderdocs/guides/1000-other_notes.md)