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

@gasbuddy/configured-swagger-client

v5.7.0

Published

A module that creates a set of swagger clients with support for inter-service tracing, custom certificates, and separated endpoint configuration

Downloads

581

Readme

configured-swagger-client

wercker status

GasBuddy has chosen Swagger as our API format for all services. Luckily, a growing number of partners are also using Swagger. Our services are written mostly in Node.js, and this module is an attempt to make the process of wiring a Node.js project to Swagger services easier and more robust.

We have a variety of "independent components":

  • -api - a Swagger API that is reachable by the outside world
  • -serv - a Swagger API that is only reachable from other services
  • -web - a non-Swagger service that exposts
  • -job - a start-and-finish job that runs periodically or on demand

All of these components likely make use of other Swagger services. Each of these services is defined by a JSON swagger specification and will use small-swagger-codegen to generate a client package. This is a departure from versions < 5.x of this library which generated a JSON spec and the client was dynamically generated. THe value of pregeneration is full type information available at development time, which includes autocompleting complex method names and request structures, which in a language like Javascript, can reduce bugs significantly without losing the flexibility (since it's just a generator doing the typing work).

One of the other important things we do is create a "CorrelationId" - a single identifier which can be traced all through the logs of all of the services that request touches. This module creates an easy way to pass that CorrelationId along in dependent service calls.

See the tests for example usage, but here's a simple one:

import PetApi from 'a-node-module-from-small-swagger-codegen';

const petApi = new PetApi(req.gb.serviceFactory);

const pets = await services.Pets.findPetsByStatus({ status: 'pending' });
// pets.obj has your pets!

API Options

The CorrelationId support is accomplished via a requestInterceptor option to the rest-api-support methods. rest-api-support also supports adding headers (such as authorization headers) in this phase. Metric collection is also enabled by the requestInterceptor/responseInterceptor pair.