Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 685 Bytes

serialization.md

File metadata and controls

38 lines (28 loc) · 685 Bytes

Serialization

Presta ships with a few default serializers to get you off the ground faster. All serializers accept a normal lambda Response and return a Response decorated with appropriate headers.

html

import { html, Response } from 'presta/serialize'

const response: Response = html({
  statusCode: 200,
  body: 'Hello world',
})

json

import { json, Response } from 'presta/serialize'

const response: Response = json({
  statusCode: 200,
  body: { title: 'Hello world' },
})

xml

import { xml, Response } from 'presta/serialize'

const response: Response = xml({
  statusCode: 200,
  body: `...`,
})