feat: Add Subscription Items API endpoints - #162
Merged
Benzilla merged 2 commits intoSep 22, 2026
Merged
Conversation
Contributor
|
Thank you! the endpoints are looking good. Few things I'd want before merging: Missing items should 404, not 400 Small things:
|
Contributor
Author
|
Thanks for the review and catching those, I just pushed a new commit addressing everything:
I've re run the tests locally and everything is perfectly green. Let me know if there's anything else you need before merging |
Contributor
|
Thanks so much! merging now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #159
Description
This PR adds public API endpoints for Subscription Items to match Stripe's API. Previously, subscription items could only be managed implicitly by updating the parent subscription. This provides developers with dedicated endpoints to manage items directly.
Files Changed:
apps/api/src/modules/Subscription.ts: Added public CRUD methods (CreateItem,GetItem,UpdateItem,DeleteItem,ListItems) for Subscription Items. These hook into the existing database models, reuse internal logic, and emit necessary webhook events (likecustomer.subscription.updated). ModifiedRequireSubscriptionto optionally validate the platform account.apps/api/src/routes/subscriptionItems.routes.ts: Created new Express routes to handle the endpoints. Validates incoming requests using the existing Zod schemas (CreateSubscriptionItemSchema,UpdateSubscriptionItemSchema,DeleteSubscriptionItemSchema).apps/api/src/routes/index.ts: Mounted the newsubscriptionItemsrouter to the/v1/subscription_itemspath.apps/api/src/__tests__/SubscriptionItem.spec.ts: Added a focused API test suite for the new Subscription Items module logic to ensure database actions and event emissions behave correctly for all 5 endpoints.Type of Change
How Was This Tested?
Tested all five CRUD operations via the new
SubscriptionItem.spec.tstest suite. Rannpx nx test apito ensure all existing test suites pass. Manually verified route registration and authentication rejection (401 vs 404) via terminal cURL.Screenshots
All test case passed

Terminal output showing the new /v1/subscription_items route returning 401 Unauthorized instead of 404 Not Found, proving the endpoint is correctly mounted.

Checklist