Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
bailiff
Advanced tools
Readme
The bailiff is a single point of config management.
Bailiff lets you access all your configs. Be it .env
, JSON files, and it also supports a central config in the mongo collection.
A central config can make it easy to share and manage common configs between your services, e.g. core DB configs.
npm install --save bailiff
You need this if you want to have central configs in Mongo DB.
BAILIFF_MONGO_USER="your-mongo-user"
BAILIFF_MONGO_PASS="your-mongo-pass"
BAILIFF_MONGO_HOST="your-mongo-host"
BAILIFF_MONGO_PORT="your-mongo-port"
BAILIFF_MONGO_DB="your-db-name"
BAILIFF_MONGO_COLLECTION="your-collection-name"
OR
BAILIFF_MONGO_URI="mongodb://user:pass@host:27017"
BAILIFF_MONGO_DB="your-db-name"
BAILIFF_MONGO_COLLECTION="your-collection-name"
You can skip this part if you are not using central config.
Run bailiff-init
before starting your node application.
We recommend you add this in the scripts
section of your package.json
.
eg: prestart: "bailiff-init"
or prestart: "npx bailiff-init"
Add bailiff
in your code.
const bailiff = require("bailiff").default;
bailiff.get("MY_CONFIG_VAR");
const bailiff = require("bailiff").default;
OR
import bailiff from "bailiff"
// To add custom Hash config data or/and a JSON file. You can chain addStore.
bailiff.addStore({"MY_CONFIG_VAR": "MY_CONFIG_VALUE", "ANOTHER_CONFIG": "ANOTHER_VALUE"})
.addStore("relative/path/to/your/json");
bailiff uses Singleton pattern. Add config store once and then use it later anywhere in the code in any file.
const bailiff = require("bailiff").default;
bailiff.get("ANOTHER_CONFIG");
The data structure of the mongo document should look like this -
{
"name": "MY_CONFIG_VAR",
"value": "MY_CONFIG_VALUE",
"status": 1
}
Make a unique index on name and status for fast search and accurate data.
You can access central config similar to other configs.
bailiff.get("MY_CONFIG_VAR");
Bailiff keeps a copy of the central mongo config.
It does not read from MongoDB every time.
It only reads from MongoDB once on the service startup. That makes it very fast.
Priority of configs are
This makes it easy to override central config if required.
FAQs
A config manager
The npm package bailiff receives a total of 26 weekly downloads. As such, bailiff popularity was classified as not popular.
We found that bailiff 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.