JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 738
  • Score
    100M100P100Q146548F
  • License MIT

Package Exports

  • koas-serializer
  • koas-serializer/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (koas-serializer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Koas Operations

Koas serializer converts a response body to the negotiated response format.

Installation

npm install koa koas-core koas-serializer

Usage

const Koa = require('koa');
const { koas } = require('koas-core');
const { serializer } = require('koas-serializer');

const api = require('./api.json');

const app = new Koa();
app.use(
  koas(api, [
    serializer({
      // Serializers
    }),
  ]),
);

Options

Koas serializer accepts a mapping of mime types to serializer functions. Serializer functions should accept the request body, and return a string or buffer.

The following serializers are supported by default:

  • application/json: The body is converted to JSON using the builtin JSON.stringify.
  • text/*: If the body is a buffer, it is returned as-is. Otherwise it is converted to a string using the toString() method.