Stone.js API
    Preparing search index...

    Interface ResourceDefinition<Model>

    What an imperatively-defined resource declares.

    The same three things a class declares, so neither paradigm can do something the other cannot.

    interface ResourceDefinition<Model = unknown> {
        data?: (model: Model, context: ResourceContext) => unknown;
        fragments?:
            | Record<string, unknown>
            | (
                (
                    context: ResourceContext,
                ) => Record<string, unknown> | Promise<Record<string, unknown>>
            );
        schema: unknown;
    }

    Type Parameters

    • Model = unknown
    Index
    data?: (model: Model, context: ResourceContext) => unknown

    Optional hook to shape or complete the model before it meets the schema.

    fragments?:
        | Record<string, unknown>
        | (
            (
                context: ResourceContext,
            ) => Record<string, unknown> | Promise<Record<string, unknown>>
        )

    Named subsets a caller may ask for, each with its own schema.

    schema: unknown

    The contract: what this resource exposes. A schema, or a function returning one.