Comments (9)
having an err
as the first argument is a nice way to opt in this behavior.
Making this type of "opt-in" fast is very complicated.
If you want to give it a stab, feel free to :).
We should start to document things as well!
from fastify.
If the input validation fails, how we want to handle it?
Add an err
field to request or add an err
object into the callback?
- Req obj:
fastify.get('/', schema, function (req, reply) {
if (req.err) return reply(req.err)
reply(null, { hello: 'world' })
})
- Err in callback:
fastify.get('/', schema, function (err, req, reply) {
if (err) return reply(err)
reply(null, { hello: 'world' })
})
Ideas?
from fastify.
I would not let it reach our handlers, silently drop it, returning a 4xx error (check the right status code)
from fastify.
You mean as it works in Hapi?
from fastify.
Yes
from fastify.
For me is ok, but in the future I would like give the user a choice about this.
from fastify.
I would personally go for @mcollina's option, returning to the client a http status code 400 error. In this way it would conform to the standard and to what most of API developers are used to.
from fastify.
If you both guys say that is the best option I'm fine with that :)
Soon the pr.
from fastify.
Another PR will come for querystring
validation, keeping this open.
from fastify.
Related Issues (20)
- `fastify.log.isLevelEnabled()` is missing from TypeScript types HOT 4
- Should send error response from a errorHandler without executing request lifecycle HOT 3
- docs: update the HTTPS server tutorial link of the section regarding TypeScript HOT 5
- Route schema might be undefined HOT 4
- Wrong DecorationMethod type
- Should "disableRequestLogging" suppress aborted requests? HOT 2
- `addContentTypeParser` doesn't work well after `await register` HOT 5
- Upload file always raises error FST_ERR_CTP_INVALID_CONTENT_LENGTH HOT 2
- Using fastify with Phusion Passenger fails with EADDRINUSE HOT 1
- How can I automatically restart my Fastify app in case of unhandled exceptions to ensure continuous server uptime in production? HOT 5
- `disableRequestLogging` should disable logs in default error handler HOT 6
- incorrect plugin identified for timeout HOT 1
- Backport webdav methods from next to current branch HOT 7
- OPTIONS HTTP method body processing HOT 3
- Dependency update for v5 HOT 1
- Merge main into next HOT 4
- Scoped FastifyRequest Customization via Generic Parameter in FastifyInstance HOT 1
- Flaky test on N|Solid 20 MacOS HOT 2
- Implement simple B-Tree for faster string comparisons HOT 5
- Throwing error in setErrorHandler after a JSON parse SyntaxError causes app to crash
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 fastify.