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:
npm install -g yonpm install -g generator-powdered-toast
Then generate your project.
Issue the following command to start the powdered-toast service locally.
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
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.
This is the internal network port for the API.
This is the API hostname that the client will use. In a Docker stack this could be different based on the port forwarding configuration.
This is the port that a client will use to hit the API.
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.
This is the protocol for the upstream services. Can be either 'http' or 'https'.
This is the upstream hostname.
This is the optional host header that will be set on proxy requests.
If set to "true" the service will run over https with self-signed certs.
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.
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.
A Swagger UI instance is included for viewing and testing the API.
Powdered-toast includes Dredd to test your API. To run Dredd tests just run the following in a terminal:
npm run dredd
Apache-2.0 © Gregory Buchenberger