Socket
Socket
Sign inDemoInstall

@paulpopat/api-interface

Package Overview
Dependencies
9
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @paulpopat/api-interface

A tool for generating simple interfaces for calling APIs accross projects


Version published
Weekly downloads
3
decreased by-84.21%
Maintainers
1
Install size
804 kB
Created
Weekly downloads
 

Readme

Source

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.

FAQs

Last updated on 12 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc