Implementing Serverless Architecture in JavaScript Applications

Best practices for building scalable and cost-effective JavaScript applications using serverless platforms like AWS Lambda and Azure Functions.

0 likes
14 views

Rule Content

{
  "title": "Implementing Serverless Architecture in JavaScript Applications",
  "description": "Best practices for building scalable and cost-effective JavaScript applications using serverless platforms like AWS Lambda and Azure Functions.",
  "category": "JavaScript Cursor Rules",
  "rules": [
    {
      "id": "serverless-modular-design",
      "description": "Ensure functions are small, focused, and stateless to promote scalability and maintainability.",
      "severity": "warning",
      "pattern": "function *\\(.*\\) *{[^{}]*}",
      "message": "Consider breaking down this function into smaller, single-purpose functions to enhance scalability and maintainability."
    },
    {
      "id": "serverless-error-handling",
      "description": "Implement robust error handling within serverless functions to manage failures gracefully.",
      "severity": "error",
      "pattern": "function *\\(.*\\) *{[^{}]*}",
      "message": "Ensure this function includes comprehensive error handling to manage potential failures effectively."
    },
    {
      "id": "serverless-security-least-privilege",
      "description": "Apply the principle of least privilege by granting only necessary permissions to serverless functions.",
      "severity": "error",
      "pattern": "function *\\(.*\\) *{[^{}]*}",
      "message": "Review the permissions assigned to this function to ensure they adhere to the principle of least privilege."
    },
    {
      "id": "serverless-logging-monitoring",
      "description": "Enable comprehensive logging and monitoring to track function performance and troubleshoot issues.",
      "severity": "warning",
      "pattern": "function *\\(.*\\) *{[^{}]*}",
      "message": "Implement logging and monitoring within this function to facilitate performance tracking and issue resolution."
    },
    {
      "id": "serverless-cold-start-optimization",
      "description": "Optimize functions to minimize cold start latency by reducing dependencies and using provisioned concurrency.",
      "severity": "warning",
      "pattern": "function *\\(.*\\) *{[^{}]*}",
      "message": "Consider optimizing this function to reduce cold start latency by minimizing dependencies and configuring provisioned concurrency."
    },
    {
      "id": "serverless-cost-optimization",
      "description": "Optimize function execution time and resource allocation to control costs effectively.",
      "severity": "warning",
      "pattern": "function *\\(.*\\) *{[^{}]*}",
      "message": "Review this function's execution time and resource usage to identify opportunities for cost optimization."
    },
    {
      "id": "serverless-input-validation",
      "description": "Validate all input data to prevent injection attacks and ensure data integrity.",
      "severity": "error",
      "pattern": "function *\\(.*\\) *{[^{}]*}",
      "message": "Implement input validation within this function to safeguard against injection attacks and maintain data integrity."
    },
    {
      "id": "serverless-ci-cd-integration",
      "description": "Integrate functions into a CI/CD pipeline to automate testing and deployment processes.",
      "severity": "warning",
      "pattern": "function *\\(.*\\) *{[^{}]*}",
      "message": "Ensure this function is part of a CI/CD pipeline to streamline testing and deployment."
    }
  ]
}