Stats

 Latest version : 1.0.9

 Last updated on 2019-02-18T13:39:55.163Z

 Keywords : typescript, serverless, lambda, function, functional, faas, rpc, http, client, jsonrpc, json, jsonschema, stdlib

 Downloads :

  • 58 in Last Month

 Links :

 Examples

¯\_(ツ)_/¯
No examples found for this package

 Readme

FTS Logo

HTTP Client for Functional TypeScript.

NPM Build Status JavaScript Style Guide

See the main docs for more info on FTS in general.

Note that this client is optional, as FTS HTTP endpoints may be called using any HTTP request library.

The advantage to using this client library is that it performs parameter and return value validation as well as handling JSON encoding / decoding. The custom encoding / decoding is really only used for non-JSON primitive types such as Date and Buffer.

Usage

Say we have the following FTS function:

export function example(name: string, date: Date): string {
  return `${name}: ${date}`
}

You can invoke this function remotely with the following client code:

import { createHttpClient } from 'fts-http-client'

// previously generated fts definition
const definition = {}

// URL of an fts-http handler endpoint
const url = 'https://example.com/foo'

// create a client that will be used to call the remote FTS function
const client = createHttpClient(definition, url)

// You may either call the remote function with the same signature as the
// original TS function or with an object of named parameters
const result0 = await client('Foo', new Date())
const result1 = await client({ name: 'Foo', date: new Date() })

Alternatives

License

MIT © Travis Fischer

 Comments