Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artcom/bootstrap-client
A library which queries and processes bootstrap data from a bootstrap server.
https://github.com/artcom/bootstrap-client
Last synced: about 1 month ago
JSON representation
A library which queries and processes bootstrap data from a bootstrap server.
- Host: GitHub
- URL: https://github.com/artcom/bootstrap-client
- Owner: artcom
- License: mit
- Created: 2019-09-25T13:31:09.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T10:04:44.000Z (about 2 years ago)
- Last Synced: 2024-12-16T23:42:35.619Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 626 KB
- Stars: 0
- Watchers: 14
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bootstrap Client
Queries bootstrap data from the [bootstrap server](https://github.com/artcom/bootstrap-server) and initializes an MQTT client and a logger for services.
## Usage
Install this library via npm:
```bash
npm install @artcom/bootstrap-client
```Bootstrap as follows:
```javascript
const bootstrap = require("@artcom/bootstrap-client")bootstrap(bootstrapUrl, serviceId).then(async ({ logger, mqttClient, queryConfig, data }) => {
// log something
logger.info("Hello world!")// publish "bar" to topic "foo"
mqttClient.publish("foo", "bar")// query some configurations with (optional) options
const myConfig = await queryConfig("config/path", { version: "master", listFiles: false, includeCommitHash = false, parseJSON = true })// use raw bootstrap data
logger.info(`I am running on device: ${data.device}`)
})
```The following additional options are supported:
- `timeout`: is the time in milliseconds until the query times out, default: `2000`
- `retryDelay`: is the time in milliseconds until the query is sent again, default: `10000`
- `debugBootstrapData`: can be set to skip querying data from the [bootstrap server](https://github.com/artcom/bootstrap-server) for debugging, default: `null`## Bootstrap Data
The client expects the following properties in the [bootstrap server](https://github.com/artcom/bootstrap-server) response or `debugBootstrapData`:
```typescript
{
tcpBrokerUri: string,
httpBrokerUri: string,
configServerUri: string,
device: string
}
```Checkout the [bootstrap server](https://github.com/artcom/bootstrap-server) documentation for details.