https://github.com/beverts312/lambda-utils
A library of convenience methods for use with AWS Lambda
https://github.com/beverts312/lambda-utils
Last synced: 3 months ago
JSON representation
A library of convenience methods for use with AWS Lambda
- Host: GitHub
- URL: https://github.com/beverts312/lambda-utils
- Owner: beverts312
- Created: 2022-04-10T13:41:24.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-10T17:00:33.000Z (about 2 years ago)
- Last Synced: 2025-02-17T21:42:36.086Z (4 months ago)
- Language: Python
- Size: 25.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Bails Lambda Utils
For making lambda's easier
`pip install bails-lambda-utils`

[](https://sonarcloud.io/summary/new_code?id=beverts312_lambda-utils)
[](https://sonarcloud.io/summary/new_code?id=beverts312_lambda-utils)## Usage
### Decorators
The libarary provides a decorator `lambda_handler` which should be attached to the any handler recieiving API calls.
The decorator will automatically map exceptions to appriorate response types:
|Exception|Response|
|-|-|
|pynamodb.exceptions.DoesNotExist|404 - Not Found|
|bails_lambda_utils.errors.PermissionError|403 - Forbidden|
|bails_lambda_utils.errors.RequiredParamException|400 - Specifying which param is missing|
|Exception|500 - With reference to aws_request_id|Example:
```
from bails_lambda_utils.handler import lambda_handler
from bails_lambda_utils.responses import Response@lambda_handler
def get(event, context={}):
#... some logic
return Response(status_code=200, message="ok").to_dict()
```### Responses + Encoders
Docs coming soon### Misc Utils
Docs coming soon