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

restutils-client

v0.3.5

Published

Generate local client library for the RESTUtils Host

Downloads

5

Readme

RESTUtils Logo

RESTUtils Host (restutils-client)

Generate local client library for APIs created with the RESTUtils Host utility with one command.

Purpose

This package is designed to work exclusively with APIs created using the RESTUtils Host utility. The RESTUtils Host utility works by instantly generating a web-based API from any JavaScript file or Node package. The generated routes can be extensive and they change as your file or package matures. The RESTUtils Client package (this one) connects to your APIs and generates a JavaScript / ES6 client library locally so you don't have to remember the upstream URLs.

Installation

It's best to run from npx but it can be installed globally...

npm i -g restutils-client

Usage

Generate a new RESTUtils Client in your project with one command...

npx restutils-client --host http://localhost:3000

... and, give it a name if you'd like ...

npx restutils-client --host http://localhost:3000 --name cool-web-api

The best part is you can issue that same one command for all of your upstream APIs...

npx restutils-client --host http://localhost:3001 --name mailboxes \
                     --host http://localhost:3002 --name processing \
                     --host http://localhost:3003 --name storage-mobile \
                     --path ~/apis

From then on, you can simply call your APIs by using simple async functions...

const apis = require('./apis/client');

const main = async () => {

  const testData = {
    ...
  };

  const result = await apis.storageMobile.messages.storeIncoming(testData);

  console.log('result:', result);

}

main();

The --host parameter is the only required param. That same example above will still work just fine, however the generateing naming becomes a bit generic. So, this...

npx restutils-client --host http://localhost:3001 \
                     --host http://localhost:3002 \
                     --host http://localhost:3003

... is used like this:

const apis = require('./restutils/client');

const main = async () => {

  const testData = {
    ...
  };

  const result = await apis.clientC.messages.storeIncoming(testData);

  console.log('result:', result);

}

main();

Environment Variables

To speed up development of your APIs, the URLs provided when you build the client are stored within the generated client.js file. However, you can easily override these URLs at any time using enviornment variables. They're displayed in the output summary:

RESTUtils Client v0.3.0
FILE : restutils/client.js
HOSTS: 3
CALLS: 4
LINES: 32
 
Override the upstream URLs using environment variables:
 
CLIENT_A_BASE=http://localhost:3011
CLIENT_B_BASE=http://localhost:3012
CLIENT_C_BASE=http://localhost:3013
 
Have a great day!

Parameters

| Name | Description | Type | Default | |--------|-----------------------|-----------------|---------| | host | URL to the API | string | | | name | Names of the API | string | | | path | Path to client folder | string (path) | |

Contact

Please feel free to contact me directly with any questions, comments, or enhancement requests:

Fred Lackey
[email protected]
http://fredlackey.com