From automation
Create mock API endpoints that plug into the @finstreet/secure-fetch pattern. Use when the backend endpoint is not ready and you need to unblock frontend work.
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin finstreet-fe-claude-pluginsThis skill uses the workspace's default tool permissions.
Mock API routes let the frontend work against realistic data before the backend is ready. They plug into the same `server.ts`/`client.ts` pattern as real endpoints — swapping to the real backend later is a one-line import change.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Mock API routes let the frontend work against realistic data before the backend is ready. They plug into the same server.ts/client.ts pattern as real endpoints — swapping to the real backend later is a one-line import change.
server.ts / client.ts
│
├── Mock: createMockServerFetchFunction(config) → /api/mock/... → mock registry
└── Real: createServerFetchFunction(config) → /api/proxy/... → Rails backend
The EndpointConfig is identical for mock and real. Only the import changes.
searchParams definition — if it does, the mock needs pagination, search, and sort support.src/shared/backend/mocks/handlers/index.ts// schema.ts stays IDENTICAL — same Zod schemas as the real endpoint
import { EndpointConfig } from "@finstreet/secure-fetch";
import { createMockServerFetchFunction } from "@/shared/backend/createMockServerFetchFunction";
import { ContractsResultSchema, ContractsPathVariablesSchema } from "./schema";
const getContractsConfig = {
protected: true,
method: "GET",
path: "/financial_service_providers/financing_cases/{product}/{financingCaseId}/contracts",
resultSchema: ContractsResultSchema,
pathVariablesSchema: ContractsPathVariablesSchema,
} satisfies EndpointConfig;
export const ContractsService = {
getContracts: createMockServerFetchFunction(getContractsConfig),
};
import { EndpointConfig } from "@finstreet/secure-fetch";
import { createMockClientFetchFunction } from "@/shared/backend/createMockClientFetchFunction";
import { ContractsResultSchema, ContractsPathVariablesSchema } from "./schema";
const getContractsConfig = {
protected: true,
method: "GET",
path: "/financial_service_providers/financing_cases/{product}/{financingCaseId}/contracts",
resultSchema: ContractsResultSchema,
pathVariablesSchema: ContractsPathVariablesSchema,
} satisfies EndpointConfig;
export const ContractsClientService = {
getContracts: createMockClientFetchFunction(getContractsConfig),
};
When the backend endpoint is ready, change the import in server.ts or client.ts:
- import { createMockServerFetchFunction } from "@/shared/backend/createMockServerFetchFunction";
+ import { createServerFetchFunction } from "@/shared/backend/createServerFetchFunction";
export const ContractsService = {
- getContracts: createMockServerFetchFunction(getContractsConfig),
+ getContracts: createServerFetchFunction(getContractsConfig),
};
Then optionally clean up: remove the mock handler file and its import from the barrel.
All mock requests pass through src/app/api/mock/[...all]/route.ts, which applies a configurable random delay to simulate network latency. This is controlled by a single config file:
src/shared/backend/mocks/mockConfig.ts
export const mockConfig = {
delay: {
enabled: true,
min: 250, // ms
max: 750, // ms
},
};
| Scenario | min | max |
|---|---|---|
| Default (realistic) | 250 | 750 |
| Slow connection | 1000 | 3000 |
| No delay (fast iteration) | — | — (enabled: false) |
The delay is applied automatically to every registered mock handler — no per-handler changes needed. When creating new mock handlers, you do NOT need to touch the delay config.
src/features/contracts/mock/contractsMock.ts){param} syntax in path patterns to match path variablestsc or pnpm commands after implementation