Skip to content
Ashlarv1.2.1

Keep fetch calls in the client

Keep every call a web app makes to its server in client/, where one module owns each endpoint.

Name fetch as the app's bridge.

ashlar.config.ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['apps'],
apps: [{ root: 'apps/web', stack: 'web', bridge: { global: 'fetch' } }],
});

A feature that calls fetch itself now breaks client-only.

apps/web/client/features/cart/load.ts
export const loadCart = () => fetch('/api/cart');
Terminal
$ pnpm exec ashlar check
Ashlar checked 3 files in 0.2 s: 1 count rose.
client-only in apps/web/client/features/cart/load.ts: 1, up from 0
apps/web/client/features/cart/load.ts:1:31
Only `client/` talks to the services.

The same call in apps/web/client/client/cart.ts passes.

See Rules for where client-only applies.