Nathan Hoad


Express Detox cleans your body

I'm not sure how useful this is but I made express-detox, a simple middleware for Express to remove unwanted posted fields from the request body.

It's pretty easy to get set up:

const { only } = require('express-detox');
const only_user_params = only('first_name', 'last_name');

/*
    POST /
        {
            first_name: 'Nathan',
            last_name: 'Hoad',
            some_other_thing: 'ignored'
        }
*/

app.post('/', [only_user_params], (request, response) => {
    // Request Body only has first_name and last_name 
    Users.create(request.body).then(user => {
        response.json(user);
    });
});

For more (up to date) information read the docs.

If I just made your day a little better then thank me with a coffee:


Vinyl Stickers, hand-crafted wooden animals, original paintings, and more
Lilly Piri on Etsy