
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
versioning for hapi, using all three methods: https://www.troyhunt.com/your-api-versioning-is-wrong-which-is/
This is a hapi plugin to manage three forms of versioning. It was inspired by Your API versioning is wrong, which is why I decided to do it 3 different wrong ways. This plugin makes it simple to implement all three methods of API versioning described in the article.
The accept header must contain version=<version>
, for example:
curl -i http://localhost:3000/api/bar -H 'Accept: version=v2'
Plugin version 1.x works for hapi 16.x
The plugin decorates the server with a methods for adding routes.
server.routev([options])
The options are the same as the route configuration object with the following additions:
version
- the version of the route. [default: 'v1']isDefault
- the default version of the route. This route, without version
prefix, will invoke the appropriate version of the route. [default: false]The following plugin options are available:
header
(string/array) - the custom header(s) to look at in order to choose which endpoint to
invoke. Returns version for first match.responseHeader
- response header to indicate which version of the route
was invoked. [default: 'version']prefix
- prefix for the route [default: '/']redirect
- whether the plugin should rewrite the url or redirect the user
with a 302 to the new endpoint [default: false]const Hapi = require('hapi');
const Hoek = require('hoek');
const HapiVersion = require('./lib');
const Blipp = require('blipp');
const server = new Hapi.Server();
server.connection({ port: 3000 });
server.register([Blipp, { register: HapiVersion, options: { prefix: '/api', redirect: true } }]);
server.routev({ version: 'v1', isDefault: true, method: 'GET', path: '/', handler: (request, reply) => {
return reply('foo');
} });
server.routev({ version: 'v1', isDefault: false, method: 'GET', path: '/bar', handler: (request, reply) => {
return reply('foo');
} });
server.routev({ version: 'v2', isDefault: true, method: 'GET', path: '/bar', handler: (request, reply) => {
return reply('bar v2');
} });
server.start((err) => {
Hoek.assert(!err, err);
});
The code above makes the following routes available:
* GET /api # alias of /api/v1
* GET /api/bar # alias of /api/v2/bar
* GET /api/v1
* GET /api/v1/bar
* GET /api/v2/bar
FAQs
versioning for hapi, using all three methods: https://www.troyhunt.com/your-api-versioning-is-wrong-which-is/
The npm package hapi-hydra receives a total of 0 weekly downloads. As such, hapi-hydra popularity was classified as not popular.
We found that hapi-hydra 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
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.