Skip to content

feat: Add CORS support and refactor response handling in Lambda funct…#13

Merged
aintnier merged 1 commit intomainfrom
responsive
Jul 25, 2025
Merged

feat: Add CORS support and refactor response handling in Lambda funct…#13
aintnier merged 1 commit intomainfrom
responsive

Conversation

@aintnier
Copy link
Copy Markdown
Owner

@aintnier aintnier commented Jul 25, 2025

…ions

  • Introduced createCorsResponse and handleOptionsRequest helper functions for consistent CORS responses.
  • Updated readDeadlines, readUsers, updateDeadlines, updateUser Lambda functions to utilize new CORS helpers.
  • Modified parameters.json to reflect the latest layer version.
  • Enhanced AddDeadline and DeadlineDetails pages with mobile sidebar functionality and responsive design improvements.
  • Implemented date formatting improvements in Dashboard and DeadlineDetails components.
  • Refined CSS styles for better responsiveness across various screen sizes.

Summary by Sourcery

Enable CORS across all Lambda endpoints with shared helper functions and streamline response handling; introduce mobile sidebar toggles in AddDeadline and DeadlineDetails pages alongside a short date formatter in Dashboard; apply extensive responsive design and truncation improvements in CSS for forms and cards; and bump the shared utils layer version.

New Features:

  • Add createCorsResponse and handleOptionsRequest helpers for uniform CORS support in all Lambda functions
  • Implement mobile sidebar toggling with hamburger header in AddDeadline and DeadlineDetails pages
  • Introduce a short date formatting utility in Dashboard for concise date displays

Enhancements:

  • Refactor all Lambda handlers to use createCorsResponse for HTTP responses and handle OPTIONS preflight
  • Expand responsive CSS for AddDeadline and DeadlineDetails pages across various breakpoints
  • Improve text truncation and styling in Dashboard cards for better layout
  • Refine form and card styling (spacing, font sizes, toggles, dropdowns) for consistent UI

Chores:

  • Update parameters.json to bump the shared homecloudSharedUtils layer version

…ions

- Introduced createCorsResponse and handleOptionsRequest helper functions for consistent CORS responses.
- Updated readDeadlines, readUsers, updateDeadlines, updateUser Lambda functions to utilize new CORS helpers.
- Modified parameters.json to reflect the latest layer version.
- Enhanced AddDeadline and DeadlineDetails pages with mobile sidebar functionality and responsive design improvements.
- Implemented date formatting improvements in Dashboard and DeadlineDetails components.
- Refined CSS styles for better responsiveness across various screen sizes.
@aintnier aintnier requested a review from Copilot July 25, 2025 20:46
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Jul 25, 2025

Reviewer's Guide

This PR centralizes CORS logic into shared helpers and refactors all Lambda handlers to use them, updates the shared layer version, and enhances the front-end with responsive layouts, mobile sidebar toggles, custom dropdown styling, and streamlined date formatting.

Sequence diagram for centralized CORS handling in Lambda functions

sequenceDiagram
    participant Client
    participant API Gateway
    participant Lambda
    participant Helper as CORS Helper

    Client->>API Gateway: HTTP request (any method)
    API Gateway->>Lambda: Invoke Lambda with event
    Lambda->>Lambda: Check event.httpMethod
    alt OPTIONS request
        Lambda->>Helper: handleOptionsRequest()
        Helper-->>Lambda: CORS preflight response
        Lambda-->>API Gateway: Return CORS preflight response
    else Other HTTP methods
        Lambda->>Helper: createCorsResponse(status, body)
        Helper-->>Lambda: Response with CORS headers
        Lambda-->>API Gateway: Return CORS response
    end
    API Gateway-->>Client: Response with CORS headers
Loading

Class diagram for shared CORS helpers and Lambda handler usage

classDiagram
    class Helper {
      +createCorsResponse(statusCode, body)
      +handleOptionsRequest()
      +validateDeadline(data)
      +getS3AvatarConfig()
      +getS3LogoConfig()
    }
    class LambdaHandler {
      +handler(event)
    }
    Helper <.. LambdaHandler : uses
    class createDeadlineHandler {
      +handler(event)
    }
    class updateDeadlinesHandler {
      +handler(event)
    }
    class deleteDeadlinesHandler {
      +handler(event)
    }
    class readDeadlinesHandler {
      +handler(event)
    }
    class createUsersHandler {
      +handler(event)
    }
    class updateUserHandler {
      +handler(event)
    }
    class deleteUserHandler {
      +handler(event)
    }
    class readUsersHandler {
      +handler(event)
    }
    class getAppConfigHandler {
      +handler(event)
    }
    Helper <.. createDeadlineHandler : uses
    Helper <.. updateDeadlinesHandler : uses
    Helper <.. deleteDeadlinesHandler : uses
    Helper <.. readDeadlinesHandler : uses
    Helper <.. createUsersHandler : uses
    Helper <.. updateUserHandler : uses
    Helper <.. deleteUserHandler : uses
    Helper <.. readUsersHandler : uses
    Helper <.. getAppConfigHandler : uses
Loading

File-Level Changes

Change Details Files
Centralize CORS response handling in Lambdas
  • Imported createCorsResponse and handleOptionsRequest
  • Added early OPTIONS-method guard
  • Replaced manual header objects with createCorsResponse calls
amplify/backend/function/*/src/index.js
amplify/backend/function/homecloudSharedUtils/lib/nodejs/helper.js
Bump shared utils layer version
  • Updated parameters.json to match latest layer version
amplify/backend/function/homecloudSharedUtils/parameters.json
Add mobile sidebar and responsive layout for AddDeadline and DeadlineDetails
  • Introduced isSidebarOpen state, toggle and close handlers
  • Rendered mobile header with hamburger and title
  • Forwarded isMobileOpen/onMobileClose props to Sidebar
  • Extended CSS with media queries for various breakpoints
src/pages/AddDeadline.js
src/pages/DeadlineDetails.js
src/styles/AddDeadline.css
src/styles/DeadlineDetails.css
Form UI enhancements: custom type dropdown
  • Built a custom dropdown container with toggle and selected indicator
  • Styled dropdown options, open/close states and hover effects
src/styles/AddDeadline.css
Improve date formatting and text truncation in Dashboard
  • Added formatDateShort helper for concise dates
  • Wrapped titles in span.title-text and applied text-overflow ellipsis
  • Updated table and cards to use new formatDateShort
src/pages/Dashboard.js
src/styles/Dashboard.css

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@aintnier aintnier merged commit 1e1f0c4 into main Jul 25, 2025
5 of 7 checks passed
@aintnier aintnier review requested due to automatic review settings March 23, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant