Getting started with Sandhands
Sandhands is used to sanitize all kinds of data in JS! Make sure to check out the
You can provide all kinds of arbitarily complex data structures, including blends of Objects, Arrays, Primitives, and more with a simple syntax. The format input allows you to define what kind of data you want to provide strictly. The exports include a set of functions exported by the library that allows you to choose what you would like to happen after sanitation is performed, as well as some other variety features.
A Basic Express Example
Sandhands provides integrated support for working with express, making it perfect for protecting your endpointsconst express = require('express')
const {sandhandsExpress} = require('sandhands')
const bodyParser = require('body-parser')
const app = express()
app.use(bodyParser.json())
app.post('/register', sandhandsExpress({
username: 'username',
email: 'email',
password: 'password'
}), (req, res) => {
console.log('Got Registration Details', req.body)
res.send('Registered')
})
const port = 8050
app.listen(port, err => {
if (err) return console.log(err)
console.log(`Server running on Port #${port}`)
})