tm-service-api
Common tm microservice api methods
Last updated 2 years ago by silentimp .
CC-BY-4.0 · Repository · Original npm · Tarball · package.json
$ cnpm install tm-service-api 
SYNC missed versions from official npm registry.

TM Micro Service API Prototype class

This class provide fetch wrapper, token and Service URL setter mainly. Just to avoid code duplication.

Requirements

Possibly you will need babel-polyfill to use it.

Documentation

ErrorBadRequest

Extends Error

Custom error message for Bad Request server response

Parameters

  • message (string | null) error details (optional, default null)

constructor

Constructor generates errorinstance

Parameters

  • message (string | null) error details (optional, default null)

Returns ErrorBadRequest current instance

ErrorNotFound

Extends Error

Custom error message for Not Found server response

Parameters

  • message (string | null) error details (optional, default null)

constructor

Constructor generates error instance

Parameters

  • message (string | null) error details (optional, default null)

Returns ErrorNotFound current instance

ErrorServerResponse

Extends Error

Custom error message for abstract server response

Parameters

  • statusCode number http status code
  • statusText string http status code text
  • message (string | null) error details (optional, default null)

constructor

Constructor generates error instance

Parameters

  • statusCode number http status code
  • statusText string http status code text
  • message (string | null) error details (optional, default null)

Returns ErrorServerResponse current instance

TMMicroServiceAPI

TM Micro Service Proto API

Parameters

  • url string service url
  • token (string | null) user access tocken if available (optional, default null)

url

Service URL

Properties

token

User access token

Properties

  • token (string | null)? user access tocken if available

constructor

Constructor saves service url

Parameters

  • url string service url
  • token (string | null) user access tocken if available (optional, default null)
  • version string service version (optional, default 'v1')

Returns TMMicroServiceAPI current instance

messages

Object with class service messages

setToken

Set access token

Parameters

setVersion

Set service version

Parameters

  • version string service version

checkUrl

Validagte URL

Parameters

  • url string service URL

  • Throws Error if URL do not match format Error will be thrown

Returns string url - service URL

checkVersion

Validate service version

Parameters

  • version string service version

  • Throws Error if URL do not match format Error will be thrown

Returns string version - service version

request

Fetch remote resource

Parameters

  • url string resource url
  • userOptions Object user defined options

Returns Promise Promise with server Response

tmpVersion

Service version

Properties

  • version string? service version

Current Tags

  • 2.0.4                                ...           latest (2 years ago)

20 Versions

  • 2.0.4                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.18                                ...           2 years ago
  • 1.0.17                                ...           2 years ago
  • 1.0.16                                ...           2 years ago
  • 1.0.15                                ...           2 years ago
  • 1.0.14                                ...           2 years ago
  • 1.0.12                                ...           2 years ago
  • 1.0.11                                ...           2 years ago
  • 1.0.10                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago

Copyright 2014 - 2017 © taobao.org |