Skip to content

feat: add GET /api/transactions endpoint with filtering and summary - #78

Merged
chitcommit merged 1 commit into
mainfrom
feat/transactions-endpoint
Apr 6, 2026
Merged

chitcommit merged 1 commit into
mainfrom
feat/transactions-endpoint

Conversation

@chitcommit

@chitcommit chitcommit commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds GET /api/transactions with filters: account_id, source, direction, category, date range, text search
  • Adds GET /api/transactions/summary/totals — aggregated totals by direction + category
  • Adds GET /api/transactions/:id — single transaction lookup
  • Pagination via limit/offset (max 200 per page)
  • Uses NULL-coalescing pattern in SQL to avoid dynamic query construction

Test plan

  • Hit /api/transactions with no filters — returns all with pagination
  • Filter by ?source=mercury&direction=outflow — returns subset
  • Hit /api/transactions/summary/totals?from=2026-01-01 — returns aggregated totals
  • Verify 404 on invalid transaction ID

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added transaction API endpoints supporting pagination and filtering by account, source, direction, category, date range, and search terms
    • Added transaction summary endpoint with aggregated data grouped by direction and category
    • Added endpoint to fetch individual transaction details

- List transactions with filters: account_id, source, direction, category, date range, search
- Pagination via limit/offset (max 200)
- GET /api/transactions/summary/totals — aggregated by direction + category
- GET /api/transactions/:id — single transaction lookup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chitcommit
chitcommit enabled auto-merge (squash) April 6, 2026 15:59
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 6, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
chittycommand-ui d3986bb Apr 06 2026, 04:00 PM

@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown
  1. @coderabbitai review
  2. @copilot review
  3. @codex review
  4. @claude review
    Adversarial review request: evaluate security, policy bypass paths, regression risk, and merge-gating bypass attempts.

@coderabbitai

coderabbitai Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: efb4d27e-e71e-4ff5-adfd-de4f5440231b

📥 Commits

Reviewing files that changed from the base of the PR and between 9c231f5 and d3986bb.

📒 Files selected for processing (2)
  • src/index.ts
  • src/routes/transactions.ts

📝 Walkthrough

Walkthrough

A new transactions API module is introduced with three GET endpoints for retrieving transaction lists, summary statistics, and individual transaction details. The module is registered in the main application router at /api/transactions.

Changes

Cohort / File(s) Summary
Transaction Routes Registration
src/index.ts
Imports and mounts new transactionRoutes module at /api/transactions endpoint.
Transaction API Endpoints
src/routes/transactions.ts
Implements three GET endpoints: list transactions with pagination and filtering (account_id, source, direction, category, date range, and text search), retrieve summary totals grouped by direction and category, and fetch individual transactions by ID with 404 handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A new route hops into place,
Transactions dance with queries and grace,
Filters and summaries, totals so bright,
Three endpoints to gather the data just right! 🎉

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/transactions-endpoint

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chitcommit
chitcommit merged commit de4e39f into main Apr 6, 2026
11 of 14 checks passed
@chitcommit
chitcommit deleted the feat/transactions-endpoint branch April 6, 2026 15:59
@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d3986bba6c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +17 to +18
const limit = Math.min(Number(c.req.query('limit')) || 50, 200);
const offset = Number(c.req.query('offset')) || 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate and clamp pagination bounds

The pagination parsing accepts negative values (?limit=-5 or ?offset=-1) and passes them straight into LIMIT/OFFSET, which causes PostgreSQL to error and the request to fall through the global 500 handler. This makes a simple malformed query string trigger an internal server error instead of a client error; clamp both values to non-negative integers (or return 400 for invalid input) before issuing SQL.

Useful? React with 👍 / 👎.

Comment on lines +23 to +27
WHERE (${accountId}::uuid IS NULL OR account_id = ${accountId}::uuid)
AND (${source}::text IS NULL OR source = ${source})
AND (${direction}::text IS NULL OR direction = ${direction})
AND (${category}::text IS NULL OR category = ${category})
AND (${from}::date IS NULL OR tx_date >= ${from}::date)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject malformed typed filters before SQL casting

This route casts raw query strings directly to uuid/date in SQL, so malformed inputs like account_id=not-a-uuid or from=2026-99-99 raise database cast errors and return 500s via the global error handler. These are user-controlled filter parameters, so they should be validated up front and rejected with 400 rather than crashing request handling.

Useful? React with 👍 / 👎.

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