npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vapor-sdk

v0.0.2

Published

This is a wrapper SDK for making API requests to the Vapor API. It provides a simple interface for making HTTP requests with retry functionality and logging.

Downloads

5

Readme

Vapor SDK Wrapper

This SDK provides a simplified, high-level interface to the Vapor 4 API. It abstracts away the details of the HTTP protocol and provides a JavaScript interface that's easy to use.

While you could use an HTTP client library like Axios directly, there are several advantages to using this SDK:

  • Simplicity: You don't need to know about HTTP methods or status codes. Just call a method on the SDK and get the data you need.

  • Consistency: The SDK ensures that every request to the API is made in a consistent way, with the same headers, error handling, etc. This makes your code more reliable and easier to debug.

  • Centralized configuration: Configure the base URL, authentication, and retry logic in one place, rather than for each request.

  • Abstraction: The SDK abstracts away the details of the API. If the API changes, you can update the SDK without changing the code that uses it.

  • Custom logic: The SDK can include custom logic specific to your application, like methods that combine multiple API requests or transform the data returned by the API.

Installation

npm install vapor-sdk

Instantiating VaporWrapper

You can instantiate the VaporWrapper with a base URL, max retries, a logger and a token like so:

// Create a new instance of the VaporWrapper class with the required options
const vapor = new VaporWrapper({
    baseURL: 'https://api.vapor.com',
    maxRetries: 5,
    logger: console,
    token: 'my-auth-token',
});

If you don't want to use any logger or don't have a token, you can pass null for the logger and omit the token:

const vapor = new VaporWrapper({
    baseURL: 'https://api.example.com',
    maxRetries: 5,
    logger: null
});

Using VaporWrapper.route

Once you have an instance of VaporWrapper, you can use the .route() method to send requests. The .route() method takes three arguments:

  1. The HTTP method as a string ('get', 'post', 'put', or 'delete').
  2. The route to which to send the request.
  3. The data to send with the request (only necessary for 'post' and 'put' requests).

For example, to send a GET request to the '/users' endpoint: const users = await vapor.route('get', '/users');

vapor.route('get', '/users')
    .then(response => {
        console.log(response);
    })
    .catch(error => {
        console.error(error);
    });

To send a POST request to the '/users' endpoint:

const data = {
    name: 'John Doe',
    email: '[email protected]'
};

vapor.route('post', '/users', data)
    .then(response => {
        console.log(response);
    })
    .catch(error => {
        console.error(error);
    });