# fts-http-client

> HTTP client for Functional TypeScript.

Latest version **1.4.0** (published 2020-03-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install fts-http-client
pnpm add fts-http-client
yarn add fts-http-client
bun add fts-http-client
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2020-03-26 |
| First published | 2019-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 3 |
| Unpacked size | 47.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 623 |
| Author | Saasify |
| Maintainers | fisch0920 |
| Keywords | typescript, serverless, lambda, function, functional, faas, rpc, http, client, jsonrpc, json, jsonschema, stdlib |

## Links

- npm: https://www.npmjs.com/package/fts-http-client
- Repository: https://github.com/transitive-bullshit/functional-typescript
- Homepage: https://github.com/transitive-bullshit/functional-typescript#readme
- Issues: https://github.com/transitive-bullshit/functional-typescript/issues
- npm.io page: https://npm.io/package/fts-http-client

## Dependencies (3)

- [fts](https://npm.io/package/fts.md) ^1.4.0
- [fts-validator](https://npm.io/package/fts-validator.md) ^1.4.0
- [isomorphic-unfetch](https://npm.io/package/isomorphic-unfetch.md) ^3.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.4.0 (latest) — 2020-03-26
- 1.3.11 — 2020-03-26
- 1.3.3 — 2019-11-18
- 1.3.0 — 2019-11-01
- 1.2.1 — 2019-10-25
- 1.2.0 — 2019-10-25
- 1.1.8 — 2019-10-06
- 1.1.7 — 2019-09-11
- 1.1.5 — 2019-08-28
- 1.1.1 — 2019-08-05
- 1.1.0 — 2019-08-05
- 1.0.9 — 2019-02-18
- 1.0.8 — 2019-01-25
- 1.0.6 — 2019-01-25
- 1.0.5 — 2019-01-24
- … 3 more at https://npm.io/package/fts-http-client/versions

## README

<a href="https://github.com/transitive-bullshit/functional-typescript" title="Functional TypeScript">
  <img src="https://raw.githubusercontent.com/transitive-bullshit/functional-typescript/master/logo.png" alt="FTS Logo" width="150" />
</a>

> HTTP Client for [Functional TypeScript](https://github.com/transitive-bullshit/functional-typescript).

[![NPM](https://img.shields.io/npm/v/fts-http-client.svg)](https://www.npmjs.com/package/fts-http-client) [![Build Status](https://travis-ci.com/transitive-bullshit/functional-typescript.svg?branch=master)](https://travis-ci.com/transitive-bullshit/functional-typescript) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io)

See the main [docs](https://github.com/transitive-bullshit/functional-typescript) 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:

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

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

```ts
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

- Node.js
  - [got](https://github.com/sindresorhus/got) - set `json` option to `true`
  - [request](https://github.com/request/request) - set `json` option to `true`
- Browser
  - [isomorphic-unfetch](https://github.com/developit/unfetch/tree/master/packages/isomorphic-unfetch)
  - [axios](https://github.com/axios/axios)
- CLI
  - [httpie](https://httpie.org)
  - [curl](https://github.com/tldr-pages/tldr/blob/master/pages/common/curl.md)

## License

MIT © [Saasify](https://saasify.sh)

---
_Source: https://npm.io/package/fts-http-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
