@fougere/adapter-rest

Entity → REST routes.

Use it

npm install @fougere/adapter-rest
// fougere.config.ts
import '@fougere/adapter-rest';

export default defineFougere({
  protocols: { rest: {} },
});

The import is what makes the word exist: without it, the editor and the boot both refuse it.

// fronds/blog/frond.config.ts
export default defineFrond({
  operations: { 'post.list': { rest: { … } } },
  protocols: { rest: { … } },
});

Every key each one admits: protocols.

What it extends

The interfaces of Fougere this package adds its words to, with declare module — see Interfaces to extend.

interfaceadds
FougereProtocolsrest
FougereOperationProtocolsrest
FougereFrondProtocolsrest

Entries: @fougere/adapter-rest

What you import

name
generateRoutesGenerate REST route definitions from a fougere App — one route per operation, per address served.
PREFIX
prefixOf
openApiOfWhat this process serves on REST, as OpenAPI 3.1, read off its routes.
describedAtWhat REST publishes of itself when protocols: says so, or undefined for any other request. Ex: {prefix}/openapi.json, {prefix}/docs.
describedPathsThe paths describedAt answers, for a router that mounts each one.
RestThe port REST's links stand in front of; a link throwing before inner.answer refuses the request. Ex: implements Partial<Rest> for a frond, extends Rest<NoteHandler> for a handler.
restDoorREST's door for one route: the one place a status is decided, read off the contract.

Types

TypeScript types only — they do not run. Import them with import type to type your own code: a variable, a parameter, an option object.

name
RouteDefinition
HttpMethod
ResponseResult
RestRoute
OpenApiDocumentOpenAPI 3.1 — the part of it this writes.
DocsPage
RestRequestWhat a host hands the REST door for one matched route — the body still to read, so the door reads it.
RestInvocationWhat a route's op is called with.
RestResponseAn answer a link at REST's door may give in the op's place, declared in its return type.
Built with Fougere and Nuxt, hosted on GitHub Pages.