@sstack/json
v1.0.0-alpha.1
Published
JSON utilities for sstack.
Downloads
11
Maintainers
Readme
@sstack/json
Easy JSON body parsing and request stringifying.
npm i @sstack/json --save
Usage
const { sstack, main } = require('sstack')
const { parse, stringify } = require('@sstack/json')
exports.handler = sstack([
parse(),
main(event => {
console.log(typeof event.body) // 'object'
}),
stringify()
])
You may also want to implement this for errors as well, if you plan to return JSON responses when throwing them.
const { sstack, main } = require('sstack')
const { parse, stringify } = require('@sstack/json')
const errors = require('./my-custom-errors.js')
exports.handler = sstack([
parse(),
main(event => {
console.log(typeof event.body) // 'object'
}),
stringify()
], [
errors(),
stringify()
])
License
MIT License © Eric Bailey