1.4.0 • Published 4 years ago

fts-http-client v1.4.0

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

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 © Saasify

1.4.0

4 years ago

1.3.11

4 years ago

1.3.3

4 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.5

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago