This lightweight Python toolkit streamlines the creation of AWS Lambda functions using the Serverless Framework. It offers a range of features to enhance your development process:
- DynamoDB: shortcuts: Avoid boilerplate code for DynamoDB operations.
- HTTP: event processing: Get the event of the HTTP request and parse it, splitting it into the path, query string, body, headers, etc.
- HTTP: response shortcuts: Create HTTP responses with the correct format and status code.
- JWT: authentication: Create and verify JWT tokens as easily as possible.
- Logger: Log messages with a format that is easy to read.
- Mappers: Remove specified fields from a dictionary or list of dictionaries.
- Parser: Convert dictionary keys to snake case or camel case.
- Password: hashing: Hash passwords with salt and verify them.
- DynamoDB: scan builder: Build a scan query with specified filters.
- Validator: Validate a dictionary with specified rules.
Attention: This package is currently undergoing maintenance. To test the package's modules, please access them directly from this repository.
Install the package with pip:
pip install py-aws-lambda-toolkit
Use the package in your code:
import logging
from py_aws_lambda_toolkit.http_event import process_event
from py_aws_lambda_toolkit.http_response import create_response
from py_aws_lambda_toolkit.status import StatusCode
from py_aws_lambda_toolkit.logger import logging
status = StatusCode()
def handler(event, context):
# Process the event
event_data = process_event(event)
event_body = event_data.get("body", {})
logging.info("Event body: %s", event_body)
# Create a response
response = create_response(
{ "ok": True, "message": "Processed event successfully" },
status=status.code_200_success,
)
return response
Contributions are welcome! For bug reports or requests please submit an issue. For code contributions please create a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
This project is in an starting phase. More documentation will be added soon and the project will be improved with more features.