Closed deleteman closed 6 years ago
By default, there is no versioning available. On the constructor, you can set the versioning strategy.
new Vatican({
versioning: true
})
Will enable default versioning behavior, which means it'll use the major version of each endpoint as part of the URL prefixed by a "v", i.e: /v1/your/endpoint
new Vatican({
versioning: {
strategy: "url",
matching: (urlV, endpointV) {
let v = urlV.substring(1);
return +v == +endpointV.split(".")[0];
}
}
})
Using the strategy property, you can set a custom version matcher for your URLs. In the above example, it'll match URLs as /1/your/api
You can also tell Vatican to use header versioning instead of modifying your URLs
new Vatican({
versioning: {
strategy: "header"
}
})
The header used will be the "Accept" header, with the following format:
accept/vnd.vatican-version.[version number]+json
@endpoint (url: /books method:post versions:[1.2, 1.3, 1.4])
This function is optional, if you don't provide a matching function, urls will contain the full version number you define for your endpoint (i.e /1.2.3/your/endpoint) and that number will be use to match it during the request.
when doing
new Vatican
we should be able to add a version to the API, so we can use it during url matching.Also, think about adding support for different versioning schemes? So by default use only major version number, but allow to setup a function that returns the version number.
Example: