Skip to content

Feature/rest user usage - #188

Merged
greatest0fallt1me merged 5 commits into
CalloraOrg:mainfrom
olaleyeolajide81-sketch:feature/rest-user-usage
Mar 27, 2026
Merged

Feature/rest user usage#188
greatest0fallt1me merged 5 commits into
CalloraOrg:mainfrom
olaleyeolajide81-sketch:feature/rest-user-usage

Conversation

@olaleyeolajide81-sketch

Copy link
Copy Markdown

#29 Add REST Route: Get Current User Usage and Stats
Repo Avatar
CalloraOrg/Callora-Backend
Description
Implement GET /api/usage (authenticated): query params (from, to, limit). Return usage events for the current user (from JWT), total spent in period, and optional breakdown by API. Use usage_events repository and requireAuth.

Requirements and context

Must require wallet auth (JWT)
Default period: current month or last 30 days
Suggested execution

Fork the repo and create a branch
git checkout -b feature/rest-user-usage
Implement changes
Route GET /api/usage with requireAuth; validate query; return events and aggregates
Add tests
Test and commit
Run tests
Example commit message: feat: REST user usage and stats
Guidelines

Clear documentation
Timeframe: 96 hours
Project details: ##29 Add REST Route: Get Current User Usage and Stats
Repo Avatar
CalloraOrg/Callora-Backend
Description
Implement GET /api/usage (authenticated): query params (from, to, limit). Return usage events for the current user (from JWT), total spent in period, and optional breakdown by API. Use usage_events repository and requireAuth.

Requirements and context

Must require wallet auth (JWT)
Default period: current month or last 30 days
Suggested execution

Fork the repo and create a branch
git checkout -b feature/rest-user-usage
Implement changes
Route GET /api/usage with requireAuth; validate query; return events and aggregates
Add tests
Test and commit
Run tests
Example commit message: feat: REST user usage and stats
Guidelines

Clear documentation
Timeframe: 96 hours
Project details: #

closes #29

Gas Optimization Bot added 5 commits March 27, 2026 10:38
- Upgrade from SHA-256 to bcrypt for secure key hashing with salt
- Implement constant-time comparison using crypto.timingSafeEqual()
- Add secure key verification method with data redaction
- Implement key rotation functionality with authorization checks
- Add comprehensive security test suite (25+ tests)
- Cover timing attacks, data exposure, and edge cases
- Ensure no raw keys are logged or exposed
- Add regression tests for common security mistakes

Security improvements:
- Prevent rainbow table attacks with bcrypt
- Prevent timing attacks with constant-time comparison
- Proper authorization checks on all operations
- Graceful error handling without information leakage
- Add comprehensive unit tests for InMemorySettlementStore
- Test persistence semantics, deduplication keys, and status transitions
- Verify data integrity and corruption resistance
- Document concurrency expectations and limitations
- Add integration tests with RevenueSettlementService
- Include detailed documentation of invariants and security considerations
- Implement production-safe Helmet security headers with environment-based configuration
- Add comprehensive Content Security Policy (CSP) with strict production settings
- Implement HTTP Strict Transport Security (HSTS) for production only
- Add X-Frame-Options, X-Content-Type-Options, Referrer-Policy headers
- Configure Cross-Origin Embedder Policy for production
- Enhance CORS with environment-based origin validation
- Add production logging for blocked CORS attempts
- Optimize preflight cache times (10min prod, 24hrs dev)
- Add comprehensive unit and integration tests for security headers
- Create detailed security configuration documentation
- Maintain development ergonomics while ensuring production safety
Implement GET /api/usage (authenticated) with query params (from, to, limit, apiId).
Return usage events for current user (from JWT), total spent in period,
and optional breakdown by API. Use usage_events repository and requireAuth.

- Add UserUsageEventQuery interface and findByUser/aggregateByUser methods
- Implement authenticated route with comprehensive parameter validation
- Support smart default period handling (last 30 days)
- Add pagination with limit parameter
- Return structured response with events, stats, and period info
- Include comprehensive test suite with 12 test cases
@drips-wave

drips-wave Bot commented Mar 27, 2026

Copy link
Copy Markdown

@olaleyeolajide81-sketch 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

@greatest0fallt1me
greatest0fallt1me merged commit 34565a1 into CalloraOrg:main Mar 27, 2026
1 check failed
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 REST Route: Get Current User Usage and Stats

2 participants