Nitrogenous Polymorphic Molecule
    Wondering what’s next for npm?Check out our public roadmap! »

    fts-http-client
    TypeScript icon, indicating that this package has built-in type declarations

    1.4.0 • Public • Published
    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 © Saasify

    Install

    npm i fts-http-client

    DownloadsWeekly Downloads

    4

    Version

    1.4.0

    License

    MIT

    Unpacked Size

    48.8 kB

    Total Files

    13

    Last publish

    Collaborators

    • avatar