Add body-size limit middleware shim for routes-b#588
Open
Johnpii1 wants to merge 3 commits into
Open
Conversation
|
@Johnpii1 is attempting to deploy a commit to the david's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Johnpii1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #554
Description
Added helper libraries under app/api/routes-b/_lib: ageing.ts (UTC day calc + bucket logic), invoice-archive.ts (include flag + filter), invoice-filters.ts (filter parsing/validation), and with-body-limit.ts (1 MiB default body-size wrapper with streaming fallback).
Extended GET /api/routes-b/invoices/overdue with ?bucketed=true to return { buckets: { 1_30, 31_60, 61_90, 90_plus }, totals } while preserving the original flat response when bucketed is absent, using UTC-based days-overdue computation.
Added archive endpoints POST /api/routes-b/invoices/[id]/archive and POST /api/routes-b/invoices/[id]/unarchive, an GET /api/routes-b/invoices/archived list, and wired ?includeArchived=true (default lists exclude archived) into invoices listing routes, implemented via the new archive helper.
Implemented multi-field filters in GET /api/routes-b/invoices (number, client, minAmount, maxAmount, currency) with validation and AND semantics using the new filter builder.
Introduced withBodyLimit and applied it to starter routes inside routes-b (branding, contacts PATCH, tags POST, webhooks POST, reminder-settings PATCH) and provided a per-route override example for avatar PATCH (2 MiB).
Added unit tests under app/api/routes-b/tests for ageing bucket boundaries and response shape, archive/unarchive behavior and default exclusion, invoice filter behavior and invalid amounts, and body-size limit scenarios.
Testing
Unit tests were added covering ageing boundaries and bucket shape, archive/unarchive and list include/exclude, invoice filter application and invalid amounts, and body-size wrapper behavior (files: app/api/routes-b/tests/.test.ts).
Attempted to run the test suite via npx vitest run app/api/routes-b/tests/.test.ts, but test execution failed in this environment due to npm registry access being blocked (403 Forbidden) so tests were not executed here.
Ran git diff --check and file/format checks completed without reported issues in this environment.