Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
hydra-integration
Advanced tools
Minimalist 'hydra integration' module, intended for Node.js web frameworks integration.
Integrating third-party Node.js web frameworks with Hydra, the simplest way.
Hydra is a NodeJS package, which facilitates building distributed applications such as Microservices. (https://www.hydramicroservice.com/)
The magic thing with Hydra is that with a minimum setup, your micro-service get 'superpowers':
By using this module, you will be able to easily integrate your prefered web framework with hydra. Just keep reading...
At the moment, the following frameworks are supported:
Next we will explain you how to create and express based micro-service on top of hydra:
IMPORTANT: Hydra depends on Redis database server for storage, cache and messaging. In case you don't have it yet: https://www.hydramicroservice.com/docs/quick-start/step1.html
npm i hydra hydra-integration express --save
Express is a dependency here because in the next example we use express, it could be koa or hapi, or any of the supported frameworks.
const HydraServiceFactory = require('hydra-integration').HydraServiceFactory;
const express = require('express');
const router = express.Router();
const factory = new HydraServiceFactory({
hydra: {
'serviceName': 'express-service-test',
'serviceDescription': 'Basic express service on top of Hydra',
'serviceIP': '127.0.0.1',
'servicePort': 3000,
'serviceType': 'express',
'serviceVersion': '1.0.0',
'redis': {
'host': '127.0.0.1',
'port': 6379,
'db': 15
}
}
});
factory.init().then(factory => factory.getService(service => {
router.get('/welcome', (req, res) => res.send('Hello World!'));
service.use('/v1', router);
}));
Alternative way of getting the service instance by passing config params to the builder (if supported):
factory.init().then(factory => factory.getService({
// optional config params here to be passed to the building strategy
bootstrap: service => {
router.get('/welcome', (req, res) => res.send('Hello World!'));
service.use('/v1', router);
}
}));
To use hydra-integration as a plugin see: The HydraIntegrationPlugin class
node app.js
pm2 start app.js -i 4
hydra-cli routes express-service-test
{
"serviceName": [
"[GET]/_health",
"[GET]/v1/welcome"
]
}
hydra-cli rest express-service-test:[GET]/v1/welcome
{
"headers": {
"x-powered-by": "Express",
"content-type": "text/html; charset=utf-8",
"content-length": "12",
"etag": "W/\"c-Lve95gjOVATpfV8EL5X4nxwjKHE\"",
"date": "Wed, 05 Apr 2017 21:22:51 GMT",
"connection": "close"
},
"body": "Hello World!",
"statusCode": 200
}
Demos available into demos folder on the git repository: https://github.com/jkyberneees/hydra-integration
FAQs
Minimalist 'hydra integration' module, intended for Node.js web frameworks integration.
The npm package hydra-integration receives a total of 3 weekly downloads. As such, hydra-integration popularity was classified as not popular.
We found that hydra-integration 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.