Skip to content

Commit 5b264fd

Browse files
dreamorosisvozza
authored andcommitted
docs(event-handler): create main structure
1 parent d36ef55 commit 5b264fd

File tree

6 files changed

+117
-18
lines changed

6 files changed

+117
-18
lines changed

docs/features/event-handler/bedrock-agents.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: Bedrock Agents
33
description: Event Handler for Amazon Bedrock Agents
4-
status: new
54
---
65

76
<!-- markdownlint-disable MD043 -->

docs/features/event-handler/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ description: Simplify routing and processing of events in AWS Lambda functions
77

88
<div class="grid cards" markdown>
99

10+
- __REST APIs__
11+
12+
---
13+
14+
Event handler for Amazon API Gateway REST and HTTP APIs, Application Loader Balancer (ALB), Lambda Function URLs, and VPC Lattice.
15+
16+
[:octicons-arrow-right-24: Read more](./rest.md)
17+
1018
- __AppSync Events API__
1119

1220
---

docs/features/event-handler/api-gateway.md renamed to docs/features/event-handler/rest.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
---
22
title: REST API
3-
description: Core utility
3+
description: Event handler for building REST APIs in AWS Lambda
4+
status: new
45
---
56

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"}.
7+
!!! warning "Feature status"
8+
This feature is under active development and may undergo significant changes. We recommend using it in non-critical workloads and [providing feedback](https://github.com/aws-powertools/powertools-lambda-typescript/issues/new/choose) to help us improve it.
99

1010
Event handler for Amazon API Gateway REST and HTTP APIs, Application Loader Balancer (ALB), Lambda Function URLs, and VPC Lattice.
1111

1212
## Key Features
1313

1414
* 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](../../features/parser.md){target="_blank"} for easy payload validation and parsing
15+
* Built-in middleware engine for request/response transformation and validation.
1716
* Works with micro function (one or a few routes) and monolithic functions (all routes)
1817

1918
## Getting started
2019

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-
2420
### Install
2521

22+
!!! info "This is not necessary if you're installing Powertools for AWS Lambda (TypeScript) via [Lambda layer](../../getting-started/lambda-layers.md)."
23+
2624
```shell
2725
npm install @aws-lambda-powertools/event-handler
2826
```
@@ -40,13 +38,13 @@ This is the sample infrastructure for API Gateway and Lambda Function URLs we ar
4038
=== "API Gateway SAM Template"
4139

4240
```yaml title="AWS Serverless Application Model (SAM) example"
43-
[//]: # ( --8<-- "examples/snippets/event-handler/rest/templates/template.yaml")
41+
--8<-- "examples/snippets/event-handler/rest/templates/api_gateway.yml"
4442
```
4543

4644
=== "Lambda Function URL SAM Template"
4745

4846
```yaml title="AWS Serverless Application Model (SAM) example"
49-
[//]: # ( --8<-- "examples/event_handler_lambda_function_url/sam/template.yaml")
47+
--8<-- "examples/snippets/event-handler/rest/templates/lambda_furl.yml"
5048
```
5149

5250
<!-- remove line below while editing this doc & put it back until the doc has reached its first draft -->
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
Transform: AWS::Serverless-2016-10-31
3+
Description: Hello world event handler API Gateway
4+
5+
Globals:
6+
Api:
7+
TracingEnabled: true
8+
Cors: # see CORS section
9+
AllowOrigin: "'https://example.com'"
10+
AllowHeaders: "'Content-Type,Authorization,X-Amz-Date'"
11+
MaxAge: "'300'"
12+
BinaryMediaTypes: # see Binary responses section
13+
- "*~1*" # converts to */* for any binary type
14+
# NOTE: use this stricter version if you're also using CORS; */* doesn't work with CORS
15+
# see: https://github.com/aws-powertools/powertools-lambda-python/issues/3373#issuecomment-1821144779
16+
# - "image~1*" # converts to image/*
17+
# - "*~1csv" # converts to */csv, eg text/csv, application/csv
18+
19+
Function:
20+
Timeout: 5
21+
MemorySize: 256
22+
Runtime: nodejs22.x
23+
Tracing: Active
24+
Environment:
25+
Variables:
26+
POWERTOOLS_LOG_LEVEL: INFO
27+
POWERTOOLS_SERVICE_NAME: hello
28+
29+
Resources:
30+
ApiFunction:
31+
Type: AWS::Serverless::Function
32+
Properties:
33+
Handler: index.handler
34+
CodeUri: hello_world
35+
Description: API handler function
36+
Events:
37+
AnyApiEvent:
38+
Type: Api
39+
Properties:
40+
# NOTE: this is a catch-all rule to simplify the documentation.
41+
# explicit routes and methods are recommended for prod instead (see below)
42+
Path: /{proxy+} # Send requests on any path to the lambda function
43+
Method: ANY # Send requests using any http method to the lambda function
44+
45+
46+
# GetAllTodos:
47+
# Type: Api
48+
# Properties:
49+
# Path: /todos
50+
# Method: GET
51+
# GetTodoById:
52+
# Type: Api
53+
# Properties:
54+
# Path: /todos/{todo_id}
55+
# Method: GET
56+
# CreateTodo:
57+
# Type: Api
58+
# Properties:
59+
# Path: /todos
60+
# Method: POST
61+
62+
## Swagger UI specific routes
63+
64+
# SwaggerUI:
65+
# Type: Api
66+
# Properties:
67+
# Path: /swagger
68+
# Method: GET
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
Transform: AWS::Serverless-2016-10-31
3+
Description: Hello world event handler API Gateway
4+
5+
Globals:
6+
Function:
7+
Timeout: 5
8+
MemorySize: 256
9+
Runtime: nodejs22.x
10+
Tracing: Active
11+
Environment:
12+
Variables:
13+
POWERTOOLS_LOG_LEVEL: INFO
14+
POWERTOOLS_SERVICE_NAME: hello
15+
FunctionUrlConfig:
16+
Cors: # see CORS section
17+
# Notice that values here are Lists of Strings, vs comma-separated values on API Gateway
18+
AllowOrigins: ["https://example.com"]
19+
AllowHeaders: ["Content-Type", "Authorization", "X-Amz-Date"]
20+
MaxAge: 300
21+
22+
Resources:
23+
ApiFunction:
24+
Type: AWS::Serverless::Function
25+
Properties:
26+
Handler: index.handler
27+
CodeUri: hello_world
28+
Description: API handler function
29+
FunctionUrlConfig:
30+
AuthType: NONE # AWS_IAM for added security beyond sample documentation

mkdocs.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ nav:
4747
- features/metrics.md
4848
- Event Handler:
4949
- features/event-handler/index.md
50+
- features/event-handler/rest.md
5051
- features/event-handler/appsync-events.md
5152
- features/event-handler/appsync-graphql.md
5253
- features/event-handler/bedrock-agents.md
@@ -162,12 +163,6 @@ plugins:
162163
- snippets/node_modules/*
163164
- snippets/package.json
164165
- snippets/CHANGELOG.md
165-
- typedoc:
166-
source: '.'
167-
output_dir: 'api'
168-
tsconfig: 'tsconfig.json'
169-
options: 'typedoc.json'
170-
name: 'API Reference'
171166

172167
- llmstxt:
173168
markdown_description: Powertools for AWS Lambda (TypeScript) is a developer toolkit to implement Serverless best practices and increase developer velocity. It provides a suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging and creating custom metrics asynchronously easier.
@@ -183,6 +178,7 @@ plugins:
183178
- features/tracer.md
184179
- features/logger.md
185180
- features/metrics.md
181+
- features/event-handler/rest.md
186182
- features/event-handler/appsync-events.md
187183
- features/event-handler/appsync-graphql.md
188184
- features/event-handler/bedrock-agents.md

0 commit comments

Comments
 (0)