Skip to content

feat: bulk endpoint registration for /api/apis/:id/endpoints/bulk#459

Merged
greatest0fallt1me merged 4 commits into
CalloraOrg:mainfrom
Paranoa-dev:feature/bulk-endpoint-registration
Jun 26, 2026
Merged

feat: bulk endpoint registration for /api/apis/:id/endpoints/bulk#459
greatest0fallt1me merged 4 commits into
CalloraOrg:mainfrom
Paranoa-dev:feature/bulk-endpoint-registration

Conversation

@Paranoa-dev

Copy link
Copy Markdown
Contributor

Bulk Endpoint Registration

Adds POST /api/apis/:id/endpoints/bulk to register multiple endpoints atomically.

Changes

New Route

  • POST /api/apis/:id/endpoints/bulk — registers multiple endpoints for an existing API in a single transaction
  • Requires authentication (bearer token or x-user-id header)
  • Validates the authenticated developer owns the API
  • Validates endpoints with Zod (bulkEndpointsSchema)
  • Returns 201 with per-row endpoint results (id, api_id, path, method, price_per_call_usdc, description)
  • Caps batch size at 50 endpoints (configurable via BULK_ENDPOINT_LIMIT)

Repository Layer

  • Added bulkCreateEndpoints(apiId, endpoints) to ApiRepository interface
  • Implemented in DrizzleApiRepository using db.transaction() — full rollback on failure
  • Implemented in InMemoryApiRepository for testing
  • Added defaultApiRepository.bulkCreateEndpoints with cache invalidation

Validator

  • Added bulkEndpointsSchema to src/validators/apiRegistration.ts
  • Reuses the existing apiEndpointRegistrationSchema for individual endpoint validation
  • Enforces min 1, max 50 endpoints

Configuration

  • Added BULK_ENDPOINT_LIMIT env var (default: 50) in src/config/env.ts

OpenAPI

  • Added /api/apis/{id}/endpoints/bulk path with request/response schemas

Tests

  • 8 new tests in src/routes/apis.test.ts covering:
    • Unauthorized access
    • Invalid API ID
    • API not found / not owned
    • Empty endpoints array
    • Invalid endpoint data
    • Successful bulk creation with per-row results
    • Exceeding the 50-endpoint limit
    • Persistence verification via GET /:id

Test Output

PASS src/routes/apis.test.ts
  POST /api/apis/:id/endpoints/bulk
    ✓ returns 401 without authentication (154 ms)
    ✓ returns 400 when id is not a positive integer (37 ms)
    ✓ returns 404 when the API does not belong to the developer (7 ms)
    ✓ returns 400 with empty endpoints array (7 ms)
    ✓ returns 400 when endpoint data is invalid (12 ms)
    ✓ creates endpoints and returns per-row results (5 ms)
    ✓ rejects more than 50 endpoints (7 ms)
    ✓ persists endpoints that can be retrieved via GET /:id (8 ms)

Closes #400

@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@Paranoa-dev 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

@Paranoa-dev Paranoa-dev force-pushed the feature/bulk-endpoint-registration branch from 6048124 to 63e2390 Compare June 26, 2026 15:07
@Paranoa-dev Paranoa-dev force-pushed the feature/bulk-endpoint-registration branch from 6149f94 to be7e2d9 Compare June 26, 2026 15:10
@greatest0fallt1me greatest0fallt1me merged commit fe3ed8e into CalloraOrg:main Jun 26, 2026
1 check failed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

bulk endpoint registration for /api/apis/:id/endpoints/bulk — merged onto current main 🚀

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 POST /api/apis/:id/endpoints/bulk to register multiple endpoints atomically through apiRepository

2 participants