Skip to content

consoless/transport-http

Repository files navigation

Build Status Coverage Dependencies XO code style

Transport Http

Sends message over the network.

Install

$ npm install --save @consoless/transport-http
or
$ yarn add @consoless/transport-http

Usage (TBD)

API

config

Type: object
Default:

{
  fieldsMap: null,
  method: 'GET',
  suppressRemoteErrors: true,
  url: null
}

Config object represents parameters which is used to send log message to remote server.

url

Request url where message bag will be sent.

method

Http method to use for request. Can be GET (default) or POST. According to method, message will be send in different ways. In case if method is GET message bag will be send as query parameters, e.g.:

http://localhost?l=error&m=hello%20world&to=3

If the method is POST then data is send as json string and Content-type: application/json is added to request headers, e.g.:

{"l":"error","m":"hello world","to":3}

fieldsMap

Defines the names of query parameters. Example:

{
  level: 'level',
  message: 'message',
  timeOffset: 'timeOffset'
}

Default values are:

{
  level: 'l',
  message: 'm',
  timeOffset: 'to'
}

suppressRemoteErrors

By default all the errors produced by request are suppressed and messages don't guaranteed to be sent. To throw errors set this option to false.

License

MIT © Alexey Lizurchik

Releases

No releases published

Packages

No packages published