@first-lego-league/ms-client
v1.3.0
Published
A HTTP client working by the Module Standard
Downloads
16
Keywords
Readme
FIRST LEGO Legaue HTTP client
A HTTP client package, wraping axios, working according to the FIRST LEGO League TMS Module Standard HTTP requests section.
Logic
This package was meant to serve as an extendable client which already works by the Module Standard and allows you to easily make requests. It gives you all the functionality needed for a HTTP client running in node or in browser.
In node
The client givven in node is fully correlated and logged using ms-client. It also has a client-id which recognizes it against other clients, and is sent in the headers for recognition.
In browser
In broswer many of these feature are not required or needed. So the client only has a client-id, and isn't correlated or logged.
Independence
All clients have the ability to be independent. This means that when they send a request and it comes back to them after failing, they will save it and retry it every givven interval.
Techincal Details
The package is an NPM package meant to be used by node servers and javascript clients. It uses axios as an engine and as a peer dependency.
Usage
You need to have axios as a dependency, then you can use the client by requiring it:
const { createClient } = require('@first-lego-league/ms-client')
const client = createClient(options)
client.get('http://some-url')
Options
The client can recieve options in order to upgrade it.
| option | meaning | options | default |
|--|--|--|--|
| logging | The logging options object. It has two fields, requestLogLevel
and responseLogLevel
| Each of the two fields can be any log level (debug
, info
, warn
, error
, fatal
) | { requestLogLevel: 'info', responseLogLevel: 'debug' }
|
| independent | Weather or not to use the independce feature | Boolean | false
|
| axiosOptions | Options object to pass to axios constructor | See axios documentation | undefined
|
| clientId | An ID for the client which you can specify if you want to control it | String | Random base64 string |
| promise | A promise class to use | Any Promise class | A global promise class. The program will fail if there is no global promise class. |
Contribution
To contribute to this repository, simply create a PR and set one of the Code Owners to be a reviewer. Please notice the linting and UT, because they block merge. Keep the package lightweight and easy to use. Thank you for contributing!