Skip to content

Add body-size limit middleware shim for routes-b#588

Open
Johnpii1 wants to merge 3 commits into
davedumto:mainfrom
Johnpii1:issue-554
Open

Add body-size limit middleware shim for routes-b#588
Johnpii1 wants to merge 3 commits into
davedumto:mainfrom
Johnpii1:issue-554

Conversation

@Johnpii1
Copy link
Copy Markdown
Contributor

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.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

@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.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 28, 2026

@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! 🚀

Learn more about application limits

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.

Add body-size limit middleware shim for routes-b

1 participant