Skip to content

RPC method registry: core + wire into ws.ts #133

Description

@harrryyd

What to build

Build RpcMethodRegistry in packages/contracts/src/ that wraps Effect RpcGroup.make() but accepts individual method registrations. Each register() call provides the method name string, its schema (the Rpc.make() result), its auth scope, and its handler. The registry lazily builds the WsRpcGroup and exposes a scope lookup map.

Wire the registry into apps/server/src/ws.ts so the RPC handler dispatch reads from the registry. Old static maps (WS_METHODS, RPC_REQUIRED_SCOPE, the handler switch) remain as fallback during migration — the server should handle methods registered either way.

Acceptance criteria

  • RpcMethodRegistry accepts register(methodName, schema, scope, handler) using MethodRegistry from Pre-factor: MethodRegistry generic utility #132
  • Registry re-registration of the same method name throws at startup
  • Registry lazily builds WsRpcGroup from all registered schemas
  • Registry exposes getScopeMap() — a Map<string, AuthEnvironmentScope> for auth middleware
  • ws.ts handler dispatch checks registry first, falls back to old static maps
  • wsRpcScopes.test.ts still passes (old map still present as fallback)
  • vp check and vp run typecheck pass

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions