Skip to content

Commit 5982f50

Browse files
dreamorosiam29d
andauthored
chore: create event-handler utility workspace (#2858)
Co-authored-by: Alexander Schueren <sha@amazon.com>
1 parent c6c425c commit 5982f50

File tree

19 files changed

+334
-11
lines changed

19 files changed

+334
-11
lines changed

.github/actions/cached-node-modules/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ runs:
4343
npm run build -w packages/idempotency & \
4444
npm run build -w packages/batch & \
4545
npm run build -w packages/testing & \
46-
npm run build -w packages/parser
46+
npm run build -w packages/parser & \
47+
npm run build -w packages/event-handler
4748
shell: bash

.github/boring-cyborg.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ labelPRBasedOnFilePath:
1818
parser:
1919
- packages/parser/src/*
2020
- packages/parser/src/**/*
21+
event-handler:
22+
- packages/event-handler/src/*
23+
- packages/event-handler/src/**/*
2124
validator:
2225
- packages/validator/src/*
2326
- packages/validator/src/**/*
@@ -53,6 +56,9 @@ labelPRBasedOnFilePath:
5356
- packages/parser/tests/*
5457
- packages/parser/tests/**/*
5558
- packages/parser/jest.config.cjs
59+
- packages/event-handler/tests/*
60+
- packages/event-handler/tests/**/*
61+
- packages/event-handler/jest.config.cjs
5662
- packages/validator/tests/*
5763
- packages/validator/tests/**/*
5864
- packages/validator/jest.config.cjs
@@ -108,6 +114,8 @@ labelPRBasedOnFilePath:
108114
- packages/tracer/README.md
109115
- packages/parser/tsconfig*.json
110116
- packages/parser/README.md
117+
- packages/event-handler/tsconfig*.json
118+
- packages/event-handler/README.md
111119
- packages/idempotency/tsconfig*.json
112120
- packages/idempotency/README.md
113121
- packages/batch/tsconfig*.json
@@ -116,8 +124,6 @@ labelPRBasedOnFilePath:
116124
- packages/commons/README.md
117125
- packages/validator/tsconfig*.json
118126
- packages/validator/README.md
119-
- packages/parser/tsconfig*.json
120-
- packages/parser/README.md
121127
- layers/tsconfig*.json
122128
- layers/README.md
123129
- examples/app/tsconfig*.json
@@ -132,6 +138,7 @@ labelPRBasedOnFilePath:
132138
- packages/parameters/package.json
133139
- packages/idempotency/package.json
134140
- packages/parser/package.json
141+
- packages/event-handler/package.json
135142
- packages/validator/package.json
136143
- packages/batch/package.json
137144
- layers/package.json

.github/scripts/release_patch_package_json.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ if (process.argv.length < 3) {
1717
}
1818
const basePath = resolve(process.argv[2]);
1919
const packageJsonPath = join(basePath, 'package.json');
20-
const alphaPackages = [];
20+
const alphaPackages = [
21+
'@aws-lambda-powertools/event-handler'
22+
];
2123
const betaPackages = [];
2224

2325
(() => {

.github/semantic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ scopes:
2222
- commons
2323
- parser
2424
- jmespath
25+
- event-handler
2526
- validation
2627
- batch
2728
- layers

.github/workflows/reusable-run-linting-check-and-unit-tests.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,29 @@ jobs:
2828
with:
2929
nodeVersion: ${{ matrix.version }}
3030
- name: Run linting
31-
run: npm run lint -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics -w packages/parameters -w packages/idempotency -w packages/batch -w packages/jmespath -w packages/parser
31+
run: |
32+
npm run lint -w packages/commons \
33+
-w packages/logger \
34+
-w packages/tracer \
35+
-w packages/metrics \
36+
-w packages/parameters \
37+
-w packages/idempotency \
38+
-w packages/batch \
39+
-w packages/jmespath \
40+
-w packages/parser \
41+
-w packages/event-handler
3242
- name: Run unit tests
33-
run: npm t -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics -w packages/parameters -w packages/idempotency -w packages/batch -w packages/jmespath -w packages/parser
43+
run: |
44+
npm t -w packages/commons \
45+
-w packages/logger \
46+
-w packages/tracer \
47+
-w packages/metrics \
48+
-w packages/parameters \
49+
-w packages/idempotency \
50+
-w packages/batch \
51+
-w packages/jmespath \
52+
-w packages/parser \
53+
-w packages/event-handler
3454
check-examples:
3555
runs-on: ubuntu-latest
3656
env:

.husky/pre-push

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ npm t \
66
-w packages/tracer \
77
-w packages/idempotency \
88
-w packages/parameters \
9-
-w packages/parser
9+
-w packages/parser \
10+
-w packages/event-handler
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: REST API
3+
description: Core utility
4+
---
5+
6+
<!-- markdownlint-disable MD013 -->
7+
???+ warning "Don't use in production (yet)"
8+
This feature is currently under development. As such it's considered not stable and we might make significant breaking changes before going [before its release](https://github.com/aws-powertools/powertools-lambda-typescript/milestone/17){target="_blank"}. You are welcome to [provide feedback](https://github.com/aws-powertools/powertools-lambda-typescript/issues/413){target="_blank"} and [contribute to the project](../../contributing/getting_started.md){target="_blank"}.
9+
10+
Event handler for Amazon API Gateway REST and HTTP APIs, Application Loader Balancer (ALB), Lambda Function URLs, and VPC Lattice.
11+
12+
## Key Features
13+
14+
* Lightweight routing to reduce boilerplate for API Gateway REST/HTTP API, ALB and Lambda Function URLs.
15+
* Support for CORS, binary and Gzip compression, Decimals JSON encoding and bring your own JSON serializer
16+
* Built-in integration with [Parser](../../utilities/parser.md){target="_blank"} for easy payload validation and parsing
17+
* Works with micro function (one or a few routes) and monolithic functions (all routes)
18+
19+
## Getting started
20+
21+
???+ tip
22+
All examples shared in this documentation are available within the [project repository](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/examples/snippets/event-handler){target="_blank"}.
23+
24+
### Install
25+
26+
```shell
27+
npm install @aws-lambda-powertools/event-handler
28+
```
29+
30+
### Required resources
31+
32+
If you're using any API Gateway integration, you must have an existing [API Gateway Proxy integration](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html){target="_blank"} or [ALB](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html){target="_blank"} configured to invoke your Lambda function.
33+
34+
In case of using [VPC Lattice](https://docs.aws.amazon.com/lambda/latest/dg/services-vpc-lattice.html){target="_blank"}, you must have a service network configured to invoke your Lambda function.
35+
36+
This is the sample infrastructure for API Gateway and Lambda Function URLs we are using for the examples in this documentation.
37+
38+
???+ info "There is no additional permissions or dependencies required to use this utility."
39+
40+
=== "API Gateway SAM Template"
41+
42+
```yaml title="AWS Serverless Application Model (SAM) example"
43+
--8<-- "examples/snippets/event-handler/rest/templates/template.yaml"
44+
```
45+
46+
=== "Lambda Function URL SAM Template"
47+
48+
```yaml title="AWS Serverless Application Model (SAM) example"
49+
--8<-- "examples/event_handler_lambda_function_url/sam/template.yaml"
50+
```
51+
52+
<!-- remove line below while editing this doc & put it back until the doc has reached its first draft -->
53+
<!-- markdownlint-disable MD043 -->

lerna.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
"packages/testing",
1111
"packages/jmespath",
1212
"packages/parser",
13+
"packages/event-handler",
1314
"examples/app",
1415
"layers",
1516
"examples/snippets"
1617
],
1718
"version": "2.6.0",
1819
"npmClient": "npm",
1920
"message": "chore(release): %s [skip ci]"
20-
}
21+
}

package-lock.json

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"packages/parser",
1616
"examples/snippets",
1717
"layers",
18-
"examples/app"
18+
"examples/app",
19+
"packages/event-handler"
1920
],
2021
"scripts": {
2122
"test": "npm t -ws",

0 commit comments

Comments
 (0)