122 lines
6.1 KiB
Markdown
122 lines
6.1 KiB
Markdown
# API Phase 5 Move Log
|
|
|
|
Date: 2026-03-17
|
|
Scope: Move `fixed-plans` endpoints out of `api/src/server.ts` into a dedicated route module.
|
|
|
|
## Route Registration Changes
|
|
- Added fixed-plans route import in [server.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/server.ts:20)
|
|
- Registered fixed-plans routes in [server.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/server.ts:948)
|
|
- New canonical route module: [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:71)
|
|
- Removed inline fixed-plans route blocks from `server.ts` to avoid duplicate registration:
|
|
- `PATCH /fixed-plans/:id/early-funding`
|
|
- `POST /fixed-plans/:id/attempt-final-funding`
|
|
- `PATCH /fixed-plans/:id/mark-unpaid`
|
|
- `POST /fixed-plans/:id/fund-from-available`
|
|
- `POST /fixed-plans/:id/catch-up-funding`
|
|
- `POST /fixed-plans`
|
|
- `PATCH /fixed-plans/:id`
|
|
- `DELETE /fixed-plans/:id`
|
|
- `POST /fixed-plans/:id/true-up-actual`
|
|
- `GET /fixed-plans/due`
|
|
- `POST /fixed-plans/:id/pay-now`
|
|
|
|
## Endpoint Movements
|
|
|
|
1. `PATCH /fixed-plans/:id/early-funding`
|
|
- Original: `server.ts` line 1414
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:71)
|
|
- References:
|
|
- [EarlyPaymentPromptModal.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/components/EarlyPaymentPromptModal.tsx:34)
|
|
- [EarlyFundingModal.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/components/EarlyFundingModal.tsx:19)
|
|
|
|
2. `POST /fixed-plans/:id/attempt-final-funding`
|
|
- Original: `server.ts` line 1475
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:131)
|
|
- References:
|
|
- [fixedPlans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/api/fixedPlans.ts:58)
|
|
- [DashboardPage.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/pages/DashboardPage.tsx:219)
|
|
|
|
3. `PATCH /fixed-plans/:id/mark-unpaid`
|
|
- Original: `server.ts` line 1635
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:287)
|
|
- References:
|
|
- [fixedPlans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/api/fixedPlans.ts:84)
|
|
|
|
4. `POST /fixed-plans/:id/fund-from-available`
|
|
- Original: `server.ts` line 1674
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:325)
|
|
- References:
|
|
- [fixedPlans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/api/fixedPlans.ts:95)
|
|
- [PlansSettings.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/pages/settings/PlansSettings.tsx:461)
|
|
|
|
5. `POST /fixed-plans/:id/catch-up-funding`
|
|
- Original: `server.ts` line 1828
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:478)
|
|
- References:
|
|
- [fixedPlans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/api/fixedPlans.ts:106)
|
|
- [PlansSettings.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/pages/settings/PlansSettings.tsx:512)
|
|
|
|
6. `POST /fixed-plans`
|
|
- Original: `server.ts` line 2036
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:659)
|
|
- References:
|
|
- [fixedPlans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/api/fixedPlans.ts:39)
|
|
- [OnboardingPage.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/pages/OnboardingPage.tsx:449)
|
|
- [fixed-plans.estimated-true-up.test.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/tests/fixed-plans.estimated-true-up.test.ts:43)
|
|
|
|
7. `PATCH /fixed-plans/:id`
|
|
- Original: `server.ts` line 2122
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:747)
|
|
- References:
|
|
- [fixedPlans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/api/fixedPlans.ts:41)
|
|
- [PlansSettings.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/pages/settings/PlansSettings.tsx:502)
|
|
|
|
8. `DELETE /fixed-plans/:id`
|
|
- Original: `server.ts` line 2239
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:866)
|
|
- References:
|
|
- [fixedPlans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/api/fixedPlans.ts:42)
|
|
- [PlansSettings.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/pages/settings/PlansSettings.tsx:443)
|
|
|
|
9. `POST /fixed-plans/:id/true-up-actual`
|
|
- Original: `server.ts` line 2285
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:911)
|
|
- References:
|
|
- [fixedPlans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/api/fixedPlans.ts:108)
|
|
- [PlansSettings.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/pages/settings/PlansSettings.tsx:549)
|
|
- [fixed-plans.estimated-true-up.test.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/tests/fixed-plans.estimated-true-up.test.ts:79)
|
|
|
|
10. `GET /fixed-plans/due`
|
|
- Original: `server.ts` line 2429
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:1054)
|
|
- References:
|
|
- [fixedPlans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/api/fixedPlans.ts:45)
|
|
- [DashboardPage.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/pages/DashboardPage.tsx:363)
|
|
|
|
11. `POST /fixed-plans/:id/pay-now`
|
|
- Original: `server.ts` line 2495
|
|
- Moved to [fixed-plans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/src/routes/fixed-plans.ts:1118)
|
|
- References:
|
|
- [fixedPlans.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/api/fixedPlans.ts:77)
|
|
- [DashboardPage.tsx](/mnt/c/Users/jholt/clone-test/SkyMoney/web/src/pages/DashboardPage.tsx:649)
|
|
- [fixed-plans.estimated-true-up.test.ts](/mnt/c/Users/jholt/clone-test/SkyMoney/api/tests/fixed-plans.estimated-true-up.test.ts:170)
|
|
|
|
## Helper Ownership in Phase 5
|
|
- Shared helper injection from `server.ts`:
|
|
- `mutationRateLimit`
|
|
- `computeDepositShares`
|
|
- `computeWithdrawShares`
|
|
- `calculateNextDueDate`
|
|
- `toBig`
|
|
- Route-local helper:
|
|
- `DAY_MS` constant for date-window computations
|
|
- `PlanBody` / `PlanAmountMode` zod schemas
|
|
|
|
## Verification
|
|
1. Build
|
|
- `cd api && npm run build` ✅
|
|
|
|
2. Focused tests
|
|
- `cd api && npm run test -- tests/fixed-plans.estimated-true-up.test.ts tests/payment-rollover.test.ts tests/transactions.test.ts`
|
|
- Result: blocked by local DB connectivity (`127.0.0.1:5432` unavailable), suites skipped/failed before endpoint assertions.
|