Full-CRUD subscription API + set-subscription script#128
Open
pmanko wants to merge 4 commits into
Open
Conversation
Scaffold for the upcoming full-CRUD subscription work. Wired up in subsequent commits alongside the new PATCH /subscription/:id handler. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Unit tests (service, controller) and an integration test exercise the not-yet-implemented full-CRUD surface: createFromDto, getById, update, delete, plus body-sniffed POST dispatch. Also adds a regression test that fails until handleSubscription properly awaits the DB write. Adds mongodb-memory-server as a devDep for the integration spec; it stands up a SubscriptionModule-only test app (no AppModule, no Agenda). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Service: add createFromDto, getById, update, delete with ObjectId validation (BadRequestException on bad id, NotFoundException on missing row). Make handleSubscription async and await the DAO write so the XML path now correctly reports failure when the write rejects. Controller: POST /subscription now sniffs body shape — parsed SOAP XML (body contains 'soap:envelope' key) still routes to handleSubscription for backward compat with OpenHIM /dsub; plain JSON routes to createFromDto. Add GET /subscription/:id, PATCH /subscription/:id, DELETE /subscription/:id. All 40 tests pass (17 service, 7 controller, 4 integration against an in-memory MongoDB, plus the pre-existing suite). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Takes OLD_URL + NEW_URL (plus optional BASE_URL), finds the
subscription whose targetAddress matches OLD_URL via the modern JSON
list endpoint, deletes it by id, then creates a new subscription
pointing at NEW_URL. Idempotent if OLD_URL is absent.
Smoke-tested end-to-end against a local mediator + Dockerized Mongo:
POST {targetAddress: http://old.example/cb} -> 201 new doc
set-subscription.sh http://old.example http://new.example
GET /subscription -> [{targetAddress: http://new.example}]
Also verified PATCH /:id, 400 on invalid id, 404 on missing id.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
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.
Summary
Adds modern REST/JSON CRUD to the
lnsp-mediatorsubscription API and a bash script to repoint a subscription at a new target URL. Preserves the legacy XMLPOST /subscriptionpath used by OpenHIM's/dsubchannel.What changes
POST /subscription— accepts JSON{targetAddress}OR the existing parsed SOAP XML (body-sniffed onsoap:envelopekey)GET /subscription/:id— get by id (404 if missing, 400 if invalid ObjectId)PATCH /subscription/:id— partial update (same error contract)DELETE /subscription/:id— delete (same error contract)handleSubscriptionfired the DB write withoutawait, so the XML path answered 200 even on DB failure. Now awaited.projects/lnsp-mediator/scripts/set-subscription.sh— delete-by-URL then POST-JSON-create, for repointing subscriptions.TDD checklist
mongodb-memory-server(red) — 4 specsUpdateSubscriptionDtowired into PATCHyarn test(40 passed / 40 total),yarn buildgreenscripts/README.mdTest plan
cd projects/lnsp-mediator && yarn test— service + controller unit specs, integration spec all green (10 suites, 40 tests)yarn buildcleanscripts/set-subscription.sh OLD NEW, confirm viaGET /subscriptionthe list is repointed ✅handleSubscriptionpreserved at the service layer. XML dispatch in the controller covered by the body-sniff unit test. The root/SOAP dispatcher inapp.controller.tsis untouched.Pre-existing issues noted (not fixed here)
test/app.e2e-spec.tshas a stalesupertestimport style and requires a real Mongo. CI runs onlyyarn test(unit), so this has been silently broken.main.tsmeansexpress-xml-bodyparseris a no-op (text parser consumes the body first). An HTTP POST of raw XML to/subscriptionhas never produced a parsed object; the XML branch is exercised only when a pre-parsed object is passed in. Out of scope for this PR.Out of scope
ValidationPipeadded (none exists today)/dsubchannel or the root/SOAP dispatcher🤖 Generated with Claude Code