Media / foldkit-media/server

MediaApi

const · packages/media/src/server/api.ts:12

const MediaApi: HttpApi.HttpApi<
  'foldkit-media',
  HttpApiGroup.HttpApiGroup<
    'images',
    HttpApiEndpoint.HttpApiEndpoint<
      'variant',
      'GET',
      '/_image/:hash/:variant',
      Schema.toCodecStringTree<
        Schema.Struct<{ hash: Schema.String; variant: Schema.String }>
      >,
      never,
      never,
      never,
      HttpApiSchema.StreamUint8Array,
      never,
      never,
      never
    >,
    false
  >
>

The media server's HTTP API: one route, a variant of an original named by its content hash. The route takes its params as text, and the handler decodes them with the space's Schema, the one Provider.hosted encodes with, so a variant outside the space is refused before any work, and that refusal, like every answer, carries the headers headersFor decides.

In the guides