1.0.1 • Published 4 years ago

koa-json-improved v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

koa-json-improved

Koa middleware returning JSON (pretty) encoded response.

Usage

Install:

yarn add koa-json-improved

Use:

import koa from 'koa';
import json from 'koa-json-improved';

const app = new koa()
app.use(json());

app.use(ctx => ctx.body = { foo: 'bar' });

Options passing (custom spacing and/or replacer):

app.use(json({ spaces: 0 })); // pretty printing disabled
app.use(json({ spaces: 2 })); // pretty printing with 2 spaces

Options

  • spaces: JSON spaces, default 4
  • replacer: JSON replacer function