@felloh-org/lambda-wrapper 1.11.190 → 1.11.191
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/CLAUDE.md +67 -0
- package/cli/seed/create-schema.js +1 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Lambda Wrapper is a shared library for Felloh serverless projects. It provides core functionality including dependency injection, logging, request handling, database entities, and response models for AWS Lambda functions.
|
|
8
|
+
|
|
9
|
+
## Common Commands
|
|
10
|
+
|
|
11
|
+
- **Build**: `yarn build` (webpack production build to `dist/`)
|
|
12
|
+
- **Build for TypeORM**: `yarn build:orm` (babel build excluding migrations)
|
|
13
|
+
- **Lint**: `yarn lint`
|
|
14
|
+
- **Test**: `yarn test` (jest with coverage)
|
|
15
|
+
- **Run migrations**: `yarn orm:migration:run`
|
|
16
|
+
- **Generate migration**: `yarn orm:migration:generate <name>`
|
|
17
|
+
- **Revert migration**: `yarn orm:revert`
|
|
18
|
+
- **Create database schemas**: `yarn orm:schema:create`
|
|
19
|
+
|
|
20
|
+
## Architecture
|
|
21
|
+
|
|
22
|
+
### Lambda Wrapper Pattern
|
|
23
|
+
The core pattern wraps Lambda handlers to provide dependency injection, logging, and error handling:
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
import { LambdaWrapper, DEFINITIONS } from '@felloh-org/lambda-wrapper';
|
|
27
|
+
|
|
28
|
+
export const handler = LambdaWrapper(configuration, async (di, request) => {
|
|
29
|
+
const warehouse = di.get(DEFINITIONS.WAREHOUSE);
|
|
30
|
+
// handler logic
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Dependency Injection
|
|
35
|
+
- `DependencyInjection` class manages service instances per request
|
|
36
|
+
- `DependencyAwareClass` is the base class for services that need DI access
|
|
37
|
+
- Built-in definitions in `src/config/dependencies.js`: LOGGER, REQUEST, WAREHOUSE, AUTHENTICATION, EVENT_BRIDGE, SECRETS, WEBHOOK, etc.
|
|
38
|
+
- Custom dependencies can be added via `configuration.DEPENDENCIES`
|
|
39
|
+
|
|
40
|
+
### Database (TypeORM)
|
|
41
|
+
- Uses TypeORM with PostgreSQL (or Aurora Data API)
|
|
42
|
+
- Entities organized by domain in `src/entity/` (payment, user, bank, agent-data, etc.)
|
|
43
|
+
- Migrations in `src/migration/` organized by schema
|
|
44
|
+
- Database schemas: user, payment, bank, agent_data, nuapay, trust_payments, total_processing, token, nuvei, reference, saltedge, acquirer, operations, basis_theory, aisp, go_cardless, planet, marketing, amex, crm, shield
|
|
45
|
+
- `WarehouseService` handles connections and supports credentials from environment or AWS Secrets Manager
|
|
46
|
+
|
|
47
|
+
### Response Model
|
|
48
|
+
All Lambda responses use `ResponseModel` which generates:
|
|
49
|
+
```javascript
|
|
50
|
+
{
|
|
51
|
+
statusCode: number,
|
|
52
|
+
headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*', ... },
|
|
53
|
+
body: JSON.stringify({ data, errors, meta: { code, reason, message, request_id } })
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Module Aliasing
|
|
58
|
+
Babel module-resolver maps `@` to the project root, allowing imports like `@/src/service/warehouse`.
|
|
59
|
+
|
|
60
|
+
## Key Directories
|
|
61
|
+
|
|
62
|
+
- `src/entity/` - TypeORM entities grouped by domain
|
|
63
|
+
- `src/migration/` - Database migrations grouped by schema
|
|
64
|
+
- `src/service/` - Core services (warehouse, logger, request, authentication, etc.)
|
|
65
|
+
- `src/event/` - Event classes for EventBridge
|
|
66
|
+
- `src/model/` - Response and data models
|
|
67
|
+
- `src/wrapper/` - Lambda wrapper implementation
|
|
@@ -34,6 +34,7 @@ const run = async () => {
|
|
|
34
34
|
await queryRunner.createSchema('marketing', true);
|
|
35
35
|
await queryRunner.createSchema('amex', true);
|
|
36
36
|
await queryRunner.createSchema('crm', true);
|
|
37
|
+
await queryRunner.createSchema('shield', true);
|
|
37
38
|
|
|
38
39
|
process.exit(0);
|
|
39
40
|
} catch (error) {
|