Files
igm 5a2e0297e5
Some checks failed
CI / ci (push) Has been cancelled
Merge branch 'more-spec'
2026-01-12 15:23:25 +08:00
..
2026-01-12 15:23:25 +08:00

@reviq/api-contract

Contract-first API definitions using oRPC and Zod for the Publisher Dashboard authentication system.

Overview

This package defines the complete API contract for all RPC procedures served at /api/v1/rpc. It uses:

  • @orpc/contract - Contract-first RPC framework
  • Zod - Runtime type validation and schema definitions
  • libphonenumber-js - Phone number validation and formatting

Structure

src/
├── index.ts              # Main exports
├── contract.ts           # oRPC contract with all procedure signatures
└── schemas/
    ├── common.ts         # Shared schemas (email, slug, phone)
    ├── auth.ts           # Authentication schemas
    ├── user.ts           # User profile and settings schemas
    ├── org.ts            # Organization schemas
    └── admin.ts          # Admin operation schemas

Usage

import { contract } from "@reviq/api-contract";
import type { loginRequestInputSchema, loginRequestOutputSchema } from "@reviq/api-contract";

// Use the contract to implement server handlers
// Use the schemas for validation and type inference
type LoginRequestInput = z.infer<typeof loginRequestInputSchema>;

API Procedures

Auth (auth.*)

  • Signup, login, logout flows
  • Email verification
  • Password reset
  • WebAuthn (passkey) support

User (me.*)

  • Profile management
  • Password and passkey management
  • Session and device management

Organizations (orgs.*)

  • Org CRUD operations
  • Member management
  • Invitations
  • Site management

Admin (admin.*)

  • Superuser-only operations
  • User and org management
  • Site assignments

Development

# Build the package
bun run build

# Watch mode
bun run dev

# Type checking
bun run typecheck

Notes

  • All emails are automatically transformed to lowercase
  • Phone numbers are stored in E.164 format
  • Slugs follow domain name rules (2-63 chars, lowercase alphanumeric with hyphens)