Skip to Content
Senri

Pretty JSON

Format JSON with prettyJSON() when ?pretty is given

import { ,  } from "@senrijs/senri";

const  = ();

.(());
.("/users", () => [{ : 1, : "alice" }]);
curl "http://localhost:3927/users?pretty"
# [
#   {
#     "id": 1,
#     "name": "alice"
#   }
# ]
  • It formats only when the query has pretty
  • Bodies over 1 MiB and streams are not formatted
  • Register it after compress() and etag()

Options

Prop

Type

On this page