Skip to content

Controller Contract

@querry-kit/nuxt deliberately does not implement a backend. Its API and composables expect a Query Kit-compatible resource controller. The endpoint name passed to useModuleApi, useTable, or useAutocomplete is appended to the configured /api/v1 base URL.

For endpoint: 'books', these are the routes exposed by useModuleApi:

MethodRouteUsed byRequired response
GET/booksquery, useTable, useAutocompletePaginated list
GET/books/:idgetOne resource
GET/books/find-by-id/:idfindByIdOne resource
GET/books/countcountNumber
POST/bookscreateCreated resource
PATCH/books/:idupdateUpdated resource
DELETE/books/:iddeleteDeleted resource

The table and autocomplete only require the list route. Mutation routes are needed only when the application calls the corresponding useModuleApi method.

Paginated List Response

The list route must return items and pagination metadata. The composables intentionally do not accept a data alias.

ts
type PaginatedResponse<T> = {
  items: T[];
  meta: {
    itemCount: number;
    pageCount: number;
  };
};

useTable reads items, meta.itemCount, and meta.pageCount. useAutocomplete reads items from the same list response.

Query Parameters

ParameterExpected byPurpose
page, perPageTable and list callersPagination.
whereTable, autocomplete, and list callersJSON-encoded Query Kit filter expression.
orderByTable and list callersJSON-encoded nested sort rules.
fieldsTable and list callersCompact field selection such as id,title,author{name}.
includeTable and list callersNested relation includes encoded with qs.

Read the query conventions for concrete serialized values. The controller must URL-decode those values and apply the same response contract.

NestJS Reference

@querry-kit/nest contains the full controller pattern, including resource reads, writes, DTO mapping, fields projection, and OpenAPI metadata. Use its CRUD Controller guide as the server-side implementation reference.

Released under the MIT License.