What's the difference between version and constraints.version in routes options? #5399
-
I'm learning Fastify and now I'm trying the api versioning feature. In the docs there are two options for the routes that seems the same thing to me:
https://fastify.dev/docs/latest/Reference/Routes/#routes-options The example in the "version" one even redirects to the constraints section of the docs. Are these options the same? is version a shortcut of constraints.version? I've tested both and aparently do the same thing... what's the difference doing: Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
They are the same, and internally the |
Beta Was this translation helpful? Give feedback.
They are the same, and internally the
version
property is added asconstraints.version
if passed while adding the route.This is currently under a deprecation notice and most likely will be drop in the next major. Its recommended to use
constraints: { version: 'x.x.x' }
instead