Comments (3)
I use Celebrate (Joi) to validate the endpoints input and Boom (made by the same person who made Joi) to report errors. With boom, the error information is not the error output. It has a special output.payload sub object which you send back to the client, while the rest of the info is for your own use (like writing to log files). I make sure to throw only Boom errors in my code, however Joi and system errors are not.. so my API error handler look like:
(err, req, res, next) => {
const errPayload = Boom.wrap(err, err.isJoi ? 400 : 500).output.payload;
if (errPayload.statusCode == 500) {
logger.error(err.stack);
}
res.status(errPayload.statusCode).json(errPayload);
}
In the code, I convert all errors to Boom errors (only if they are not ones already) and add the right status. Then I return the error output payload.
from celebrate.
Yeah that's a fine way to do it. In your case, using your own error handler would probably be the way to go as I'm not planning on introducing boom
into this module. This bug is for specifically Celebrate.errors()
which leaks the entire validated object back to the client.
I'll probably just end up copying what hapi does when it formats joi
errors.
from celebrate.
After reviewing this, I've removed the bug label. Worse case scenario is the client gets back the sent object which they've already got. So no big deal.
from celebrate.
Related Issues (20)
- Question: should full mode collect multiple errors per segment? HOT 2
- Assertion error on validating an uri HOT 10
- Validate multipart/form-data HOT 1
- Error details are empty in error message HOT 6
- Difference between 'body' and '[Segments.BODY]' (Question) HOT 4
- Set default value if validation is failed. especially for query params which are optional HOT 6
- Swagger integration HOT 2
- Full mode validation can not be enabled HOT 3
- Validating a form data json object? HOT 3
- Mode FULL doesn't seem to be working. HOT 2
- Examples in TypeScript too HOT 2
- ChainAlert: npm package release (15.0.1) has no matching tag in this repo HOT 1
- Type definitions for converted data HOT 2
- node 16 Object.defineProperty compatibility HOT 2
- Compatebility with Prisma and prisma-joi-generator HOT 2
- joi.alternatives error message too generic HOT 3
- feat: infer typing from celebrate args HOT 1
- Option to not call next with errors HOT 2
- Migrate away from TravisCI to Github Actions HOT 1
- Nested schema error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from celebrate.