
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
mini-client
Advanced tools
Simplistic µService library
Mini-client is a generic client for µServices built with mini-service. The goal of mini-service is to give the minimal structure to implement a µService, that can be invoked locally or remotely.
Its principles are the following:
mini-client & mini-service use the latest ES6 features, so they requires node 6+
Please checkout the API reference
This project was kindly sponsored by nearForm.
Mini-client expose a generic client that can be wired to any service exposed with mini-service. It provides an JavaScript object, that will fetch exposed APIs and creates a function for each of them. This allow to invoke remote API like if they were plain function (it's a kind of good old RPC).
caller-remote.js
const getClient = require('mini-client')
const calc = getClient({
remote: 'http://localhost:3000'
})
calc.add(10, 5).then(sum => console.log(`Result is: ${sum}`))
Each API will end-up as a function (named after the API itself) that returns a promise. Calling a function that isn't an exposed API will fails as if you try to invoked an unknown property of a regular object.
At the first call, mini-client fetch from the remote server the exposed API and creates the actual functions.
After being initialized, a mini-client can't be wired to another service, and will always try to invoke the one it was initiliazed with.
Please note that you can call init() (see bellow), which doesn't do anything in "remote mode".
While calling remote service is a realistic scenario for production environments, it's more convenient to run all code in the same unit on dev (for debugging) and in continuous integration.
That's why mini-client can run the in "local mode". In this case, the service definition is loaded at initialization.
caller-local.js
const getClient = require('mini-client')
const calcService = require('./calc-service')
const calc = getClient(calcService)
calc.init().then(() =>
calc.add(10, 5).then(sum => console.log(`Result is: ${sum}`))
)
Two noticeable difference with "remote mode":
init() prior to any call, which run exposed API initialization code
(as if the server were starting)Then, you can invoke exposed APIs as function like in "remote mode".
When invoking an exposed API, Mini-client can report parameters validation error. If the distant service denies the operation because of a missing or errored parameter, the returned promise will be rejected with the appropriate error message.
When Mini-client is running in remote mode, it caches remote exposed API at first call. But what would happened if a new version of remote server is redeployed ?
If the list of newer exposed API equals the one used when Mini-client was started, everything will be fine. But if the two lists are different, then there's a chance that Mini-client will invoke URLs that don't exist any more, or requires different parameters.
To detect such changes, the CRC-32 checksum of the exposed Api list is sent by remote server in the X-Service-CRC response header.
On each call, Mini-client will compare that checksum with the one valid when it initialized.
If both value differs, then Mini-Client will:
Remote server isn't compatible with current client (expects service-name@x.y.z)
When Mini-client is running on local mode, such situation can never happen.
Copyright Damien Simonin Feugas and other contributors, licensed under MIT.
None: v4 is using async/await, which requires node@8+. Code is fully backward compatible.
Groups are now used as sub-objects of mini-client.
Given a service exposing:
ping without group (or if group has same name as overall service)a with apis ping & pongb with api pingthe final Mini-client will be:
client = {
ping(),
a: {
ping(),
pong()
},
b: {
ping()
}
}
Local services, as remote services, must have name and version options defined
When loading services, the services property was renamed to groups, and serviceOpts is now groupOpts:
const {startServer} = require('mini-service')
startServer({
groups: [ // was services previously
require('../serviceA'),
require('../serviceB'),
require('../serviceC')
],
groupOpts: { // was serviceOpts previously
serviceA: {},
serviceB: {},
serviceC: {}
}
})
FAQs
Mini client for mini services: Micro services done simply
The npm package mini-client receives a total of 9 weekly downloads. As such, mini-client popularity was classified as not popular.
We found that mini-client 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.