Add @trails-cool/api package with Zod schemas for REST API contract
Single source of truth for the Journal REST API: - API_VERSION semver constant (1.0.0) - Endpoint path constants (routes, activities, auth, uploads, push) - Zod schemas for all request/response shapes: - Routes: list, detail, create, update, compute - Activities: list, detail, create - Auth: token exchange, refresh, device management - Discovery: instance info + API version - Uploads: presigned URL flow - Errors: structured error response with field-level details - Cursor-based pagination schemas - TypeScript types inferred from Zod (z.infer) Used by Journal server (validation) and mobile client (type safety). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
572d240ed1
commit
49b304749e
13 changed files with 349 additions and 0 deletions
35
packages/api/src/endpoints.ts
Normal file
35
packages/api/src/endpoints.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/** Typed API endpoint path constants */
|
||||
export const ENDPOINTS = {
|
||||
discovery: "/.well-known/trails-cool",
|
||||
|
||||
auth: {
|
||||
token: "/api/v1/auth/token",
|
||||
devices: "/api/v1/auth/devices",
|
||||
device: (id: string) => `/api/v1/auth/devices/${id}` as const,
|
||||
},
|
||||
|
||||
routes: {
|
||||
list: "/api/v1/routes",
|
||||
create: "/api/v1/routes",
|
||||
detail: (id: string) => `/api/v1/routes/${id}` as const,
|
||||
update: (id: string) => `/api/v1/routes/${id}` as const,
|
||||
delete: (id: string) => `/api/v1/routes/${id}` as const,
|
||||
compute: "/api/v1/routes/compute",
|
||||
},
|
||||
|
||||
activities: {
|
||||
list: "/api/v1/activities",
|
||||
create: "/api/v1/activities",
|
||||
detail: (id: string) => `/api/v1/activities/${id}` as const,
|
||||
delete: (id: string) => `/api/v1/activities/${id}` as const,
|
||||
},
|
||||
|
||||
uploads: {
|
||||
presign: "/api/v1/uploads",
|
||||
},
|
||||
|
||||
push: {
|
||||
subscribe: "/api/v1/push/subscribe",
|
||||
unsubscribe: "/api/v1/push/unsubscribe",
|
||||
},
|
||||
} as const;
|
||||
Loading…
Add table
Add a link
Reference in a new issue