Skip to content

Commit 5982f50

Browse files
dreamorosiam29d
andauthored
chore: create event-handler utility workspace (#2858)
Co-authored-by: Alexander Schueren <[email protected]>
1 parent c6c425c commit 5982f50

19 files changed

+334
-11
lines changed

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

+2-1
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

+9-2
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

+3-1
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

+1
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

+22-2
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

+2-1
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
+53
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

+2-1
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

+15-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
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",

packages/event-handler/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Powertools for AWS Lambda (TypeScript) - Event Handler Utility
2+
3+
> [!Warning]
4+
> 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). You are welcome to [provide feedback](https://github.com/aws-powertools/powertools-lambda-typescript/issues/413) and [contribute to the project](https://docs.powertools.aws.dev/lambda/typescript/latest/contributing/getting_started/).
5+
6+
Powertools for AWS Lambda (TypeScript) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda/typescript/latest/#features).
7+
8+
You can use the library in both TypeScript and JavaScript code bases.
9+
10+
## Intro
11+
12+
Event handler for Amazon API Gateway REST and HTTP APIs, Application Loader Balancer (ALB), Lambda Function URLs, and VPC Lattice.
13+
14+
## Usage
15+
16+
To get started, install the library by running:
17+
18+
```sh
19+
npm i @aws-lambda-powertools/event-handler
20+
```
21+
22+
> [!Note]
23+
> This readme is a work in progress.
24+
25+
## Contribute
26+
27+
If you are interested in contributing to this project, please refer to our [Contributing Guidelines](https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/CONTRIBUTING.md).
28+
29+
## Roadmap
30+
31+
The roadmap of Powertools for AWS Lambda (TypeScript) is driven by customers’ demand.
32+
Help us prioritize upcoming functionalities or utilities by [upvoting existing RFCs and feature requests](https://github.com/aws-powertools/powertools-lambda-typescript/issues), or [creating new ones](https://github.com/aws-powertools/powertools-lambda-typescript/issues/new/choose), in this GitHub repository.
33+
34+
## Connect
35+
36+
- **Powertools for AWS Lambda on Discord**: `#typescript` - **[Invite link](https://discord.gg/B8zZKbbyET)**
37+
- **Email**: <[email protected]>
38+
39+
## How to support Powertools for AWS Lambda (TypeScript)?
40+
41+
### Becoming a reference customer
42+
43+
Knowing which companies are using this library is important to help prioritize the project internally. If your company is using Powertools for AWS Lambda (TypeScript), you can request to have your name and logo added to the README file by raising a [Support Powertools for AWS Lambda (TypeScript) (become a reference)](https://s12d.com/become-reference-pt-ts) issue.
44+
45+
The following companies, among others, use Powertools:
46+
47+
- [Hashnode](https://hashnode.com/)
48+
- [Caylent](https://caylent.com/)
49+
- [Trek10](https://www.trek10.com/)
50+
- [Elva](https://elva-group.com)
51+
- [globaldatanet](https://globaldatanet.com/)
52+
- [Bailey Nelson](https://www.baileynelson.com.au)
53+
- [Perfect Post](https://www.perfectpost.fr)
54+
- [Sennder](https://sennder.com/)
55+
- [Certible](https://www.certible.com/)
56+
- [tecRacer GmbH & Co. KG](https://www.tecracer.com/)
57+
- [AppYourself](https://appyourself.net)
58+
- [Alma Media](https://www.almamedia.fi)
59+
60+
### Sharing your work
61+
62+
Share what you did with Powertools for AWS Lambda (TypeScript) 💞💞. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (TypeScript) [here](https://docs.powertools.aws.dev/lambda/typescript/latest/we_made_this).
63+
64+
### Using Lambda Layer
65+
66+
This helps us understand who uses Powertools for AWS Lambda (TypeScript) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When [using Layers](https://docs.powertools.aws.dev/lambda/typescript/latest/#lambda-layer), you can add Powertools as a dev dependency to not impact the development process.
67+
68+
## License
69+
70+
This library is licensed under the MIT-0 License. See the LICENSE file.
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
displayName: {
3+
name: 'Powertools for AWS Lambda (TypeScript) utility: EVENT HANDLER',
4+
color: 'blue',
5+
},
6+
runner: 'groups',
7+
moduleNameMapper: {
8+
'^(\\.{1,2}/.*)\\.js$': '$1',
9+
},
10+
transform: {
11+
'^.+\\.ts?$': 'ts-jest',
12+
},
13+
moduleFileExtensions: ['js', 'ts'],
14+
collectCoverageFrom: ['**/src/**/*.ts', '!**/node_modules/**'],
15+
testMatch: ['**/?(*.)+(spec|test).ts'],
16+
roots: ['<rootDir>/src', '<rootDir>/tests'],
17+
testPathIgnorePatterns: ['/node_modules/'],
18+
testEnvironment: 'node',
19+
coveragePathIgnorePatterns: ['/node_modules/', 'src/types/index.ts'],
20+
coverageThreshold: {
21+
global: {
22+
statements: 100,
23+
branches: 100,
24+
functions: 100,
25+
lines: 100,
26+
},
27+
},
28+
coverageReporters: ['json-summary', 'text', 'lcov']
29+
};

0 commit comments

Comments
 (0)