bragg-safe-guard

Prevents leaking information outside the bragg context

Usage no npm install needed!

<script type="module">
  import braggSafeGuard from 'https://cdn.skypack.dev/bragg-safe-guard';
</script>

README

bragg-safe-guard Build Status

Prevents leaking information outside the bragg context

Install

$ npm install --save bragg-safe-guard

Usage

const bragg = require('bragg');
const safeGuard = require('bragg-safe-guard');

const app = bragg();

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

app.use(safeGuard('unicorn', 'user.password'));

app.use(ctx => {
    console.log(ctx.body);
    //=> {foo: 'bar', user: {name: 'Hello'}}
});

exports.handler = app.listen();

API

safeGuard(...properties)

Returns a bragg middleware function.

properties

Type: string[]

List of properties to be removed from the body before sending the response.

Related

  • bragg - AWS λ web framework

License

MIT © Sam Verschueren