2.0.1 • Published 3 years ago

@paulpopat/api-interface v2.0.1

Weekly downloads
26
License
ISC
Repository
github
Last release
3 years ago

Api Interface

This is a tool to generate type safe and simple interfaces that wrap around remote API interfaces.

npm install @paulpopat/api-interface --save

It is recomended that you use my type checking library with this, but it is not essential.

npm install @paulpopat/safe-type --save

To use it, you simply do as so:

import GenerateInterface from "@paulpopat/api-interface";
import { IsString } from "@paulpopat/safe-type";

const interface = GenerateInterface(
    {
        authenticate: {
            method: "GET",
            url: "api/auth",
            parameters: { username: IsString, password: IsString },
            returns: IsString
        }
    },
    {
        base: "http://localhost:8080/",
        // Optional
        headers: {
            Accept: "application/json"
        }
    }
);

// I have never actually used this password ;)
await interface.authenticate({ username: "paulpopat", password: "paul123" });

For more information, please consult the typings for the project.

2.0.1

3 years ago

2.0.0

3 years ago

1.1.12

4 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago