2.0.1 • Published 2 years ago

@paulpopat/api-interface v2.0.1

Weekly downloads
26
License
ISC
Repository
github
Last release
2 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

2 years ago

2.0.0

2 years ago

1.1.12

3 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago