Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
consistency
Advanced tools
A hapi.js plugin for versioning your API. Borne out of this talk: http://www.slideshare.net/shakefon/hapidays-2014
npm install consistency
server.register({
register: require('consistency'),
options: {
uriParam: 'apiVersion',
acceptNamespace: 'consistencyExample',
customHeaderKey: 'api-version'
}
}, function (err) {
if (err) console.log('Consistency plugin failed to load');
});
or, via Glue and manifest:
var manifest = {
connections: [...],
plugins: {
consistency: {
uriParam: 'apiVersion',
acceptNamespace: 'consistencyExample',
customHeaderKey: 'api-version'
}
}
};
Glue.compose(manifest, function (err, server) {
...
});
server.route({
id: 'array',
method: 'GET',
path: '/array',
handler: {
versioned: [
function(request, reply) {
reply({
version: '1.0'
});
},
function(request, reply) {
reply({
version: '2.0'
});
}
]
}
});
server.route({
id: 'object',
method: 'GET',
path: '/object',
handler: {
versioned: {
'v1.0': function(request, reply) {
reply({
version: '1.0'
});
},
'v2.0': function(request, reply) {
reply({
version: '2.0'
});
},
'v1.5': function(request, reply) {
reply({
version: '1.5'
});
}
}
}
});
A version can be provided with or without the v prefix and can also be provided
using the latest
keyword which will use the latest versioned endpoint.
Matching of version handlers is cached to remove redundent checks based on the route method and route path.
If an endpoint has not changed in a specific version of the api, we can omit it and the matcher will use the version that is closest to the one request. for example if in version 2 we didn't update the users endpoint a request would return version 1
If you provide the version in shorthand (v1, 1) it will return greatest version available for that api version. for example given the versions 1, 1.2, 1.5 providing 1 will return 1.5.
FAQs
API versioning plugin for hapi.js
The npm package consistency receives a total of 56 weekly downloads. As such, consistency popularity was classified as not popular.
We found that consistency demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.