traPtitech / traPtitech/Checkin

main 由来の prices/products/invoices/checkout と auth 由来の payments/membership の機能重複を整理する

Open
#53 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
0
Forks
0
Avg merge
3d 5h
Merged PRs (30d)
7

Description

現状

packages/api/src/router.ts が束ねる 8 つのルーターのうち、次の 3 組が同じ対象を扱っている。

  • Invoice の一覧: invoices.listpayments.listInvoices
  • Checkout Session の一覧: checkout.sessions.listpayments.listCheckoutSessions
  • Invoice の発行: invoices.issuemembership.issueInvoice / membership.issueSpecialInvoice / membership.issueSpecialInvoiceByEmail

認可の付き方が組ごとに違う。pricesproductsinvoicescheckout の 4 つのルーターは packages/api/src/orpc.tspub で実装されていて認可ミドルウェアを持たず、変更系だけが同じファイルの assertMutationsEnabled で塞がれている。paymentsadminProcmembershipuserProcadminProc で実装されている。

画面から呼ばれているのは後者だけである。2026-09-18 に git grep -ohE '\$orpc\.[a-zA-Z.]+' -- 'apps/web/app' | sort -u で数えたところ、apps/web/app が呼ぶプロシージャは authmembershippaymentspayouts の 12 個で、pricesproductsinvoicescheckout を呼ぶ箇所は 0 だった。

誰が何を誤るか

Invoice の一覧や発行に手を入れる人が、2 つあるルーターのどちらが正しい置き場所かを判断できない。認可の弱い pub の側に足すと、無認証で到達できる経路が増える。また、両者の出力の形が違う(invoices.list は Stripe の語彙をほぼそのまま写し、payments.listInvoicesproductpaymentIddashboardUrl を持つ正規化済みの行)ので、一方だけを直すと画面と管理用の経路で見えるものがずれる。

取りうる手

  • 画面から呼ばれていない pricesproductsinvoicescheckout を契約から外す
  • 認可を payments / membership と揃えたうえで、管理用のエンドポイントとして残す
  • 出力の形を payments の正規化済みの行に寄せ、invoices.list を内部化する

直さずに残した理由

削除も認可の付与も公開している契約の変更で、#15 が決める認可の形に結論が依存する。認可の形が決まる前に片方を消すと、決まった後で作り直しになる。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/api/src/router.ts and packages/api/src/orpc.ts to map the overlapping routers and their authorization middleware. Check the web call sites with the documented git grep command, then read issue #15 before choosing whether to remove, secure, or internalize the unused procedures. Done means the duplicate contract and authorization behavior are resolved consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, authorization, backend, backend-api-design
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.