superjson icon indicating copy to clipboard operation
superjson copied to clipboard

Koa/Express Middleware

Open nrdobie opened this issue 5 years ago • 0 comments

This middleware will allow for SuperJSON to be used as part of an API server. Intial plan is to support Koa and Express.

Proposed Usage

import Koa from 'koa'
import bodyParser from 'koa-bodyparser'
import { koaSuperJSON } from '@onedeadpixel/superjson-middleware'

const app = new Koa()

app.use(bodyParser())
app.use(koaSuperJSON())

// ctx.request.body will now be parsed by SuperJSON
// ctx.response.body will now be stringified by SuperJSON

nrdobie avatar Jul 19 '19 16:07 nrdobie