b122de518c
File path = route. JSON/JSON5, dynamic .ts handlers + faker, templating, stateful CRUD (pagination/sort/persist), __variants, sequence, chaos, rate-limit, auth, validation, per-route + global proxy/record, splat routes, X-Scenario overlays, SSE. Visual docs (Scalar) at /__docs from a live OpenAPI 3 spec. OpenAPI import script. Zero-build via tsx. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
21 lines
716 B
TypeScript
21 lines
716 B
TypeScript
import type { MockContext } from '../../../src/respond.ts'
|
|
|
|
// shown in the visual docs (/__docs) — handler-level description
|
|
export const doc = {
|
|
summary: 'Synthetic user',
|
|
description: 'Deterministic faker user keyed off `:id`. Add `?verbose=1` for a bio.',
|
|
}
|
|
|
|
// feature: dynamic handler + faker + path param + query
|
|
// try: /__test/users/5 · /__test/users/5?verbose=1
|
|
export default function ({ params, query, faker }: MockContext) {
|
|
faker.seed(Number(params.id) || 1) // deterministic per id
|
|
return {
|
|
id: params.id,
|
|
name: faker.person.fullName(),
|
|
email: faker.internet.email(),
|
|
avatar: faker.image.avatar(),
|
|
bio: query.verbose === '1' ? faker.lorem.paragraph() : undefined,
|
|
}
|
|
}
|