bragg-wrap-response

1.0.0 • Public • Published

bragg-wrap-response Build Status

Wraps any result in the body in an extra object on the bragg context

Adds a date to the body in the response bragg context

Install

$ npm install --save bragg-wrap-response

Usage

const bragg = require('bragg');
const wrapResponse = require('bragg-wrap-response');

const app = bragg();

app.use(ctx => {
	ctx.body = {
		foo: 'bar',
		unicorn: 'rainbow',
		user: {
			name: 'Hello',
			password: 'world'
		}
	};
});

app.use(wrapResponse());

app.use(ctx => {
	console.log(ctx.body);
	//=> { date: 2018-03-23T20:50:28.373Z, result: { foo: 'bar', unicorn: 'rainbow', user: { name: 'Hello', password: 'world' } }}
});

exports.handler = app.listen();

API

wrapResponse({options})

Returns a bragg middleware function.

options

Type: object
Default: {date: true', key: 'data'}

Related

  • bragg - AWS λ web framework

License

MIT © Bart Callant

/bragg-wrap-response/

    Package Sidebar

    Install

    npm i bragg-wrap-response

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    4.02 kB

    Total Files

    4

    Last publish

    Collaborators

    • bartcallant