inkan

Routes

A route and its contract: params, query, body, responses.

.(
  "/teas",
  {
    : "Add a tea",
    : ["teas"],
    : NewTea,
    : { 201: Tea, 409: .() },
    : [
      { : "a new oolong", : { : "Da Hong Pao", : "oolong" }, : { : 2 } },
      { : "no name", : { : "green" }, : 400 },
    ],
  },
  ({ ,  }) => {
    const  = store.add();
    return (201, , { : `/teas/${.id}` });
  },
);
field
params, query, headers, bodyschemas for the input. Header names are lowercase.
responsestatus โ†’ schema. The first 2xx is the default status, and no body means 204.
examples{ name, params, query, headers, body, status, expect, keep, after }. status defaults to the first 2xx. expect is a part of the answer that has to be there. keep and after chain examples, see below.
summary, description, tags, deprecated, operationIdfor the docs
hiddenkeeps the route out of the docs and OpenAPI
usemiddleware for this route only, after validation

A handler returns a value, or reply(status, body, headers) for anything else. ctx.reply is typed to the statuses in the contract, so reply(418) on a route that never promised a teapot does not compile.