Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@paulpopat/api-interface

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

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

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
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

Package last updated on 12 Jun 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc