Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including bragg-safe-guard with all npm packages installed. Try it out:

var braggSafeGuard = require("bragg-safe-guard")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bragg-safe-guard v2.0.0

Prevents leaking information outside the bragg context

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

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free