Add fake payment API#15
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db4b12b9e2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }), | ||
| })(async (req, ctx) => { | ||
| const { payment_id } = await req.json() | ||
| const payment = ctx.db.updatePaymentStatus(payment_id, "completed") ?? null |
There was a problem hiding this comment.
Share the payment store across requests
In the real Next/Winterspec handler (pages/api/[[...route]].ts), no shared DB middleware is injected, so withDb creates a new in-memory store whenever ctx.db is absent; only tests/fixtures/start-server.ts supplies a process-wide DB. Because this endpoint looks up a payment created by a previous /payments/send HTTP request, production calls to /payments/complete after sending will return null (and /payments/get or /payments/list will similarly see an empty store), making the new payment lifecycle unusable outside the test fixture.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ff80a6e. withDb now falls back to a process-wide shared store when production does not inject ctx.db, while tests can still inject isolated DBs. I also added a regression test that sends and completes a payment through a Winterspec bundle without any injected DB middleware, covering the lifecycle path from the review.
Implements a focused fake payment lifecycle API for the template Winterspec app.
Changes:
Verification:
/claim #1