Skip to content

Server Manifests And Clients

Chris Michael edited this page Jul 18, 2026 · 2 revisions

Effuse

Server Manifests And Clients

Status: Manifest creation and runtime clients are current. Generated module and CLI workflows are experimental.

A layer server manifest is a serializable inventory of layer-owned routes, actions, methods, validation metadata, runtime hints, cache/CORS metadata, and diagnostics.

Create A Manifest

const manifest = createLayerServerManifest([AuthLayer, UserLayer]);

The manifest is built from resolved layer definitions. Duplicate action names, invalid route declarations, and metadata conflicts are reported as diagnostics rather than hidden by declaration order.

Typed Runtime Client

const client = createLayerServerManifestClient(manifest);

const user = await client.action('users', 'refreshUser', {
  userId: 'u1',
});

const response = await client.route('/api/users/[id]', {
  method: 'GET',
  params: { id: 'u1' },
});

Literal manifests constrain layer names, action names, route paths, HTTP methods, and dynamic params at compile time.

Route URL Generation

createLayerRoutePath and createLayerRouteUrl replace colon or bracket params and encode dynamic values. Required catch-alls require values. Optional catch-alls may omit their segment.

Generated Module

const source = generateLayerServerClientModule(manifest, {
  factoryName: 'createApiClient',
  manifestName: 'serverManifest',
});

The generated module exports a literal manifest, client factory, and inferred client type. Generation should be deterministic and reviewed like source code.

Client Errors

Manifest clients distinguish:

  • unknown manifest routes/actions before dispatch;
  • transport and HTTP failures;
  • typed action failures;
  • structured layer server error bodies;
  • structured validation error bodies.

Use isLayerClientError, status helpers, and body helpers rather than parsing error messages.

Current Boundary

The manifest currently describes layer server capabilities. It is not yet the single source for client page routes, layouts, route metadata, and server files. That unification is tracked by #218.

Related

Clone this wiki locally