Stone.js API
    Preparing search index...
    interface ResourcesConfig {
        envelope?: ResourceEnvelopeConfig;
        onViolation?: "warn" | "throw";
        params?: { fields?: string; fragment?: string; include?: string };
        registry?: Record<string, IResource<any, any>>;
    }

    Hierarchy (View Summary)

    Index

    The envelope this application wraps its payloads in, if it wraps them at all.

    A handler answering a page returns something like { items: [...], meta: { total } }, and items and meta are not fields of a model: shaping that object would publish the wrapper as if it were the thing. Naming the word once is enough, and everything around the payload is left as it was, counts and cursors included.

    blueprint.set('stone.resources.envelope', { payload: 'items' })
    

    Undeclared by default, because guessing which key holds the payload would quietly mangle a model that happens to have one by that name.

    onViolation?: "warn" | "throw"

    What to do when a projection breaks the contract its resource publishes.

    throw (the default) refuses to answer, because a caller cannot detect a broken contract and a consumer generated from it breaks on the field that is missing. warn chooses availability over integrity, explicitly, and puts the breach in the log.

    params?: { fields?: string; fragment?: string; include?: string }

    The query parameters a caller uses to ask for a shape.

    Configuration rather than convention: an API that already answers ?only= keeps its vocabulary instead of gaining a second one. Defaults: fields, include, view.

    registry?: Record<string, IResource<any, any>>

    Named resources a route can refer to by name, instead of importing them at the route.

    blueprint.set('stone.resources.registry', { user: userResource })
    // then, on the route: { resource: 'user' }

    Naming a resource that is not registered fails loudly at request time rather than returning the model unshaped, because an unshaped model is exactly what a resource exists to prevent.