Created
September 15, 2024 02:28
-
-
Save metaskills/7e8f3f00b8111f10fa72ba6077bdcb1b to your computer and use it in GitHub Desktop.
Typical Node/JavaScript Lambda Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This project is a Node.js application that emphasizes a simple, object-oriented design using JavaScript classes. It leverages modern JavaScript features and is structured for clarity and maintainability. The application is deployed using AWS Lambda's SAM framework to utilize services like SQS and S3. Common scripts for setup, testing, and deployment are located in the `bin` directory, and testing is conducted with Jest, focusing on public interfaces. | |
## Use Existing Styles | |
- Adhere to the project's existing styles and naming conventions. | |
## Object-Oriented Design | |
- Favor simple, object-oriented approaches using classes. | |
- Each file in the `src` directory should export a single class. | |
- Utilize all JavaScript class features, including: | |
- Static methods | |
- Private fields and methods (using `#`) | |
## Testing with Jest | |
- Write tests that only target the public interfaces exposed by classes. | |
- Avoid testing internal implementation details. | |
## AWS Lambda Deployment | |
- Provide high-level guidance for building out `template.yaml` as needed for AWS SAM. | |
- Leverage AWS services like SQS and S3 where appropriate. | |
## Scripts in `bin` Directory | |
- Acknowledge the existence of common scripts for setup, testing, and deployment. | |
## Modern ES6+ Features | |
- Encourage the use of modern JavaScript features where suitable. | |
- Recommendations include: | |
- Arrow Functions: Use for concise function expressions. | |
- Destructuring: Apply to extract values from objects and arrays. | |
- Template Literals: Utilize for string interpolation. | |
- Promises and Async/Await: Manage asynchronous operations cleanly. | |
- Spread and Rest Operators: Simplify array and object manipulation. | |
## Error Handling | |
- Avoid unnecessary `try/catch` blocks. | |
- Do not be overly defensive; handle errors where it adds value. | |
## Logging | |
- Encourage the use of `console.log` where needed, as logs can be monitored via CloudWatch. | |
- Do not be overly defensive with logging. | |
- When logging objects, favor formatting them using `JSON.stringify` for readability. | |
## Comments | |
- Encourage clear and concise comments to explain complex logic and intentions. | |
- Use comments to improve code readability and maintainability. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment