ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Registry.Npm.Serve

Description

npm's client-facing error body, as a codec.

The agnostic serve layer decides the HTTP status of a refusal; the body shape is npm's, and it lives here as one NpmError type with an autodocodec codec. That codec is the single source of truth: the serve path encodes the wire denial from it, and the capability manifest renders the same codec to the documented schema (in its own tier, so openapi3 never reaches the proxy). npm clients read the human-facing reason from a JSON {"error": …} object, matching npm's own denial bodies.

There is no separate renderer handle. A route's abstract ResponseContract pairs each status with its body codec, the handler receives only constructors for values admitted by that contract, and the emitted body is therefore the documented body by construction.

Synopsis

Documentation

newtype NpmError Source #

npm's client-facing error body: a JSON object carrying the human-facing reason under a single error string (npmErrorKey). One codec backs both the wire encoding and the documented schema, so the served body and its documentation cannot diverge.

Constructors

NpmError 

Fields

npmErrorCodec :: JSONCodec NpmError Source #

npm's error-body codec: the source of truth for its wire form and documented schema.

npmErrorKey :: Text Source #

The JSON key an npm denial body carries its reason under.

npmError :: Maybe HelpMessage -> Text -> NpmError Source #

Build an npm error body from the human-facing reason and the operator help message, appending the help (if any) as the serve path has always done.