Skip to content

refactor(orpc): standardize the single-record GET path (/show/{id} vs /{id}) #9

Description

@ciokan

Moved out of studio/TODO.md (see #6).

some contracts have show while others have get: one or the other

Problem

The single-record GET route path is inconsistent across contracts:

Contract Path
campaigns.ts:44 /show/{id}
leads_labels.ts:14 /show/{id}
projects.ts:11 /{id}
leads_lists.ts:12 /{id}
campaigns_sequences_versions.ts:47 /{id}

The procedure is named get in all of them; only the URL differs.

The /show/ segment is not arbitrary — contract/campaigns.ts:42 documents why:

// the /show/ segment is required, otherwise {id} would overwrite all other

A bare /{id} under a prefix that also has sibling static segments (e.g. /campaigns/sequences, /campaigns/counters, /leads/lists, /leads/labels) swallows those siblings. So /show/{id} is needed exactly where a router shares its prefix with sub-routers, and unnecessary where it doesn't.

Decision needed

Pick one and apply it everywhere:

  1. /show/{id} everywhere — uniform and immune to future sub-routers being added under any prefix, at the cost of a slightly unusual REST shape.
  2. /{id} where it is safe, /show/{id} only where a prefix collision exists — more conventional REST, but the rule is subtle and easy to break later (adding /projects/templates would silently break /projects/{id}).

Recommendation: option 1, for predictability — but that is the call to make here.

Scope

All of packages/orpc/src/contract/*.ts single-record GET routes, the matching apps/api/src/modules/** controllers, and any dashboard query files under apps/dashboard/src/tanstack/query/** that hit them. Rebuild packages/orpc afterwards. Also worth documenting the final rule in CONTRIBUTING.md / CLAUDE.md so it stops drifting.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions