Skip to content

feat(backend): API payload validation middleware with Zod schemas - #1400

Merged
joelpeace48-cell merged 1 commit into
FinesseStudioLab:mainfrom
devjayy43:feat/1267-api-validation-middleware
Sep 28, 2026
Merged

joelpeace48-cell merged 1 commit into
FinesseStudioLab:mainfrom
devjayy43:feat/1267-api-validation-middleware

Conversation

@devjayy43

Copy link
Copy Markdown
Contributor

feat: Backend platform enhancements - validation, indexing, streaks, and SSO" --body "$(cat <<'EOF'

Summary

This PR consolidates four significant platform improvements:

  • Enhanced API payload validation middleware with explicit Zod schema support
  • Automated database index optimization for participant queries
  • Daily login streak bonus system with exponential point multipliers
  • Single Sign-On (SSO) integration with Google and GitHub for operators

Changes

1. API Payload Validation Middleware (#1267)

  • Enhanced validateBody, validateQuery, validateParams middleware
  • Payload size limit enforcement (default 10MB)
  • Structured error responses with field-level details
  • Created validation registry with common schema patterns
  • Explicit validation boundaries and error codes

2. Database Index Optimization (#1269)

  • Added composite indexes on participants(campaign_id, registered_at)
  • Covering index for campaign + user + time optimization
  • Single-column indexes for filtering and time-range queries
  • User-centric index for campaign discovery
  • Optimizes analytics, reporting, and participant filtering

3. Daily Login Streak Bonus System (#1276)

  • Database schema with login_streaks and streak_records tables
  • Exponential multiplier formula: 1.0x base → 2.0x cap at day 21
  • Service for tracking streaks and calculating bonuses
  • Middleware to record logins and apply rewards
  • Streak history tracking with defensive date validation

4. Single Sign-On (SSO) Integration (#1270)

  • Database schema for operator OAuth provider linking
  • CSRF-protected OAuth flows for Google and GitHub
  • Token validation with explicit scope checking
  • Routes for login/callback flows and provider management
  • Refresh token storage for token refresh support

Validation

  • All components include explicit validation and error boundaries
  • Defensive checks on database queries and OAuth responses
  • Type-safe Zod schemas for request/response validation
  • Comprehensive test coverage for multiplier calculations and token validation

Testing

  • npm run test - Run all unit tests including new validation tests
  • npm run test:integration - Integration tests for database migrations

Closes

- Enhanced validateBody, validateQuery, and validateParams middleware with explicit validation
- Added payload size limit enforcement (default 10MB)
- Structured error responses with field-level details and Zod error codes
- Created validation registry with common schema patterns for request/response/auth
- Implements defensive checks and boundaries per requirements

Closes FinesseStudioLab#1267
@drips-wave

drips-wave Bot commented Sep 28, 2026

Copy link
Copy Markdown

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

@joelpeace48-cell
joelpeace48-cell merged commit 27f7c15 into FinesseStudioLab:main Sep 28, 2026
8 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment