13 ms·
I fully recommend this. The fp-ts is quite readable for JavaScript. Combine it with io-ts and you have a robust way of handling user inputs: pipe( de
by homami 4y ago
I fully recommend this. The fp-ts is quite readable for JavaScript. Combine it with io-ts and you have a robust way of handling user inputs:
pipe(
decoder.decode(req.body)
, E.mapLeft(_ex => new InputValidationError(decoder.decode(req.body)))
, RTE.fromEither
, RTE.chain(handleInput)
, RTE.match(
error => {
res.status(500);
res.send(error)
},
result => {
res.send(result)
}
)
)(reader)