mosaic-toolkit
v1.0.0
Published
Reusable NodeJS - TypeScript utilities for AWS Lambda
Readme
Mosaic - AWS Lambda Template (NodeJS and TypeScript)
This project serves as a template for creating AWS Lambda functions using Node.js and TypeScript.
It aims to provide a foundation for developing serverless applications on AWS platform with Integrations (Ingress and Egress) mentioned below.
Integrations
Ingress (Lambda Handlers)
- Lambda
- Kafka
- API Gateway
- S3
Egress (Service Clients)
- Hasura
- Kafka - MSK
- Function - AWS Lambda
- Object Storage - S3
- Secrets Management - AWS Secrets Manager
- Microservices - ECS (TBD)
- Application Config - Launch Darkly (TBD)
Technical Specifications
Runtime - NodeJS
Language - TypeScript
Libraries
- AWS SDK - Used to Call S3, Lambdas, ECS, Secret Manager
- Lambda Power Tools - Used for Logging Framework
- Axios - Used to Call Hasura, External API's
- Kafka JS - Used to Produce Messages to Kafka
- Webpack - Used for Transpiling the TypeScript Code, minify and Bundle it
- Jest - Unit Testing Framework
- ES Lint - Static Code Analyzer
- Prettier - Code Formatter
- Gradle - Dependency Management, Release Versioning
- Zod - Validation Library
- Handlebars - Templating Engine
- Date Fns - Date Manipulation Library
Steps to create a new Lambda Function
- Run the Github Actions Workflow in https://github.com/VMobilitySandbox/DeveloperTools to create your own repos based on the template
- Start by updating the necessary configuration (Name, Description) in the package.json and folder structure to reflect the name of the service.
- Remove the Dependencies from package.json which are not necessary for your application.
- Rename the Lambda handler file to index.ts (index_Kafka.ts becomes index.ts).
- Remove any redundant handler files that are not needed for the service.
- Review the contents of the Client and Config folders, retaining only the clients and configurations essential for the service. Delete any unnecessary files within these folders.
- Remove any unnecessary Jest Test Files or Integration Test Files not needed for your application.
- In the InitializationService.ts file, include only the function calls necessary for the initialization phase of your service. Remove any unused function calls.
- Remove the provided DummyService and DummyModels files, as they are only provided for reference and are not required for the service.
- Update the default-config.json and env-config.json file with the default configurations required for your service. These configurations can be overridden if necessary using Lambda Environment Variables.
- Run npm install to download the dependencies.
- Ensure that SERVICE_NAME and ENVIRONMENT are added to the default-config.json.
- Create a README.md file based on the template provided in APP_README.md, filling in all necessary details about the service.
- Create a CHANGELOG.md file based on the template provided in APP_CHANGELOG.md, documenting all changes made in each release of the service. Include details about enhancements, bug fixes, and any other modifications made.
Note
- This is a template with boilerplate code, Ensure that you integrate the necessary services and thoroughly test it.
- Avoid implementing any business logic within the handler.
- The code within the handler of the template is solely for demonstration purposes.
- Refer to Development Workflow - Best Practices in https://dev.azure.com/atsol/Mosaic/_wiki/wikis/Mosaic.wiki/2107/Development-Workflow-Best-Practices
Pending Items
- Launch Darkly Integration
Integration Testing
Integration Testing can be done in AWS Workspace using the Test classes provided in integration folder
- Configure your Integration Test File name correctly in .vscode\launch.json
- Use the Run and Debug pane in VS Code to run the Integration Test
