boomack-js
v0.11.2
Published
CLI client for boomack
Downloads
4
Readme
Boomack API Client Library
A JavaScript library for sending display and configuration requests to a Boomack server.
See https://boomack.com for further information about the Boomack server.
For the library documentation see: https://docs.boomack.com/client/boomack-js/.
Getting Started
import { Boomack } from 'boomack-js'
async function main() {
const client = new Boomack({
server: { url: 'http://127.0.0.1:3000' },
})
const response = await client.displayMediaItems({
panel: 'default',
slot: 'default',
text: 'Hello World!',
type: 'text/plain',
})
if (response.success) {
console.log("Request was successful.")
} else {
console.error("Request failed with:", response.statusMessage)
console.log(response.body)
}
}
main().catch(console.error)
Loading Configuration
The configuration for the Boomack API client is by convention loaded from the following sources and merged in the given order:
- Default configuration
- Default configuration files
.boomack-server[.json|.yaml|.yml]
in the user profile directoryboomack-server[.json|.yaml|.yml]
in the current working directory.boomack[.json|.yaml|.yml]
in the user profile directoryboomack[.json|.yaml|.yml]
in the current working directory
- Additional configuration files (JSON/YAML)
- Environment Variables starting with
BOOMACK_
BOOMACK_SERVER_URL
BOOMACK_CLIENT_TIMEOUT
BOOMACK_CLIENT_TOKEN
- ...
- An explizit configuration map
The default configuration has lowest priority and the explicit configuration map has the highest.
import boomack from 'boomack-js'
async function main() {
const client = await boomack.withConfig({
loadDefaultFiles: true,
additionalFiles: ['./my-config.json'],
loadEnvironmentVars: true,
config: {
// explicit configuration
client: { timeout: 5000 },
},
})
await client.display({
text: 'Hello World!',
type: 'text/plain',
})
}
main().catch(console.error)
Using Response Data
The methods of the Boomack client are returning HTTP response objects.
If the property success
is true
, the body
property
contains the parsed JSON data.
import boomack from 'boomack-js'
async function main() {
const client = await boomack.withConfig({
loadDefaultFiles: true,
loadEnvironmentVars: true,
config: {
client: {
// use application/json as accepted response format
format: 'application/json',
},
},
})
const response = await client.listPanels()
if (response.success) {
// the body property contains the parsed JSON response
const panelIds = response.body
console.log("Panel IDs:", panelIds)
} else {
console.error("Request failed with:", response.statusMessage)
}
}
main().catch(console.error)
The expected output is:
Panel IDs: [ 'default' ]