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

generator-powdered-toast

v1.1.3

Published

>

Downloads

6

Readme

generator-powdered-toast NPM version Build Status Dependency Status Coverage percentage

About

Generator-powdered-toast uses Yeoman to generate a mock server based on a Swagger specification. This is useful for front-end development when you have a swagger specification of an API that is being actively developed. No more waiting for the API developers to deploy to a development server. Get started building your boss UX right away.

Have a production or development API that is being changed? You can seemlessly proxy requests not specified in the Swagger to those upstream services by adding an optional proxy.

The powdered-toast server uses the following technolgy stack:

  • hapi.js - A badass Node.js REST server from the ninjas at Walmart.com.
  • A fork of Swagmock - A Swagger based mocking library.
  • swaggerize-hapi - A Swagger based hapi.js plugin.
  • hapi-swaggered-ui - A Swagger UI implementation for hapi.js.
  • h2o2 - A proxy handler plugin for hapi.js.

Making Powdered Toast

Make sure you have pre-installed node.js, npm, and Yarn. Install Yeoman and generator-powdered-toast globally using npm.

npm install -g yo
npm install -g generator-powdered-toast

Then generate your project.

yo powdered-toast

Running Your Shiny New Powdered Toast

Issue the following command to start the powdered-toast service locally.

npm start

Environment

Powdered-toast uses dotenv to configure environmental variables. Take a look at the .env file in the root of the project. A description of the variables follows the example.

API_HOST=localhost
API_PORT=9980
UI_HOST=localhost
UI_PORT=9980
WS_PORT=9981
TLS_ENABLED=true
PROXY_UPSTREAM_PROTOCOL=http
PROXY_UPSTREAM_HOST=api.example.com
PROXY_HEADER_HOST=client.example.com
DEBUG=server,proxy

API_HOST

This is the host name within the server network dns. When you run powdered-toast locally it will generally match the UI_HOST value. However, sometimes you may have different values as in a Docker stack.

API_PORT

This is the internal network port for the API.

UI_HOST

This is the API hostname that the client will use. In a Docker stack this could be different based on the port forwarding configuration.

UI_PORT

This is the port that a client will use to hit the API.

WS_PORT

This is the web sockets port used by the debugger UI.

NOTE: When powdered-toast runs in TLS mode the debugger UI is currently not working. There is an issue with connecting over wss.

PROXY_UPSTREAM_PROTOCOL

This is the protocol for the upstream services. Can be either 'http' or 'https'.

PROXY_UPSTREAM_HOST

This is the upstream hostname.

PROXY_HEADER_HOST

This is the optional host header that will be set on proxy requests.

TLS_ENABLED

If set to "true" the service will run over https with self-signed certs.

DEBUG

There are currently two debuggers - one in the main server file and one the proxy controller. These are activated my adding them to a comma seperated string. To turn off debugging, remove the entries.

Regenerate from Swagger using Yeoman

In the case you want to mofify the Swagger specification, the following command will use Yeoman to regenerate handlers and data.

npm run regenerate

If there are conflicts you will be prompted to overwrite.

Swagger UI

A Swagger UI instance is included for viewing and testing the API.

/swagger-ui

Dredd Testing

Powdered-toast includes Dredd to test your API. To run Dredd tests just run the following in a terminal:

npm run dredd

License

Apache-2.0 © Gregory Buchenberger