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

@pixelprodotco/appstrap

v0.6.0

Published

Uber-configurable mock server for bootstrapping single page apps

Downloads

14

Readme

Appstrap

Appstrap is an interactive tool for REST api mocking. It is powered by node.js and express.

Driven by a simple but powerful configuration, your mock api can adapt its complexity to the needs of your application. From a single endpoint that responds with a simple json payload, to an in-depth set of functions that provide a realistic stand-in for your production server - you can do it with appstrap.

Appstrap's mission:

  • Isolate applications or services at their REST boundaries
  • Ensure easy reproduction of bugs in local from other environment sources
  • Ensure higher code quality before the code even hits your ci/cd pipeline
  • Eliminate reliance on other services/tiers to be in place

As in all good things, Appstrap was born from necessity. I often found myself spending more time setting up data, waiting on unreliable environments, or even waiting on other services to be ready than I spent developing my code.

I wanted something that was dead simple to use, could effectively mock any external service without my app knowing the difference, and something that would help make my integration tests easy to transition to qa and production.

Previous attempts to solve this problem included creating a bunch of json files for "fake" data to inject. Although it was servicable for getting data back from a service, it did nothing in terms of interaction between a service. I found I was pushing bugs into qa that had more to do about what happens after I interact with a service than anything else. Something had to change.

With Appstrap, all data can now be mocked on the fly. Changes as a result of a service interaction are now reflected the next time data is retrieved. The same integration tests we run against qa and production can run right along side of my unit tests. Life is better with Appstrap. Follow the getting started guide below to use Appstrap in your project today!

Getting started

Install via NPM

npm install --save-dev @pixelprodotco/appstrap

Set up your config file

At the root of your project, run the following command

appstrap init

After answering the prompts, a new configuration file will be created for you.

If you prefer to make your own config file instead, you may do so. When the server is started, it looks for the config at.appstrap/config.js relative to the root of your project directory. This can be overridden by invoking the appstrap constructor with the property configPath: './your/path/here' or via command line with -c ./your/path/here

The table below illustrates the building blocks of a config file.

|Property|Type|Purpose| | |---|---|---|---| |bundle|Object|If you are developing a single page application, by specifying a bundle, the server will add the necessary logic to serve the single page app and enable client side routing. |(optional)| |initialState|Object|When the server is started, req.state will be set to an empty object - {} - by default. Override that behavior and prime in some initial state here.|(optional)| |assets|Array|Any folders that contain static files that may be requested from your server should be declared here. If you arent serving any static files, provide an empty array.|required| |endpoints|Array|Specify a collection of endpoints here. These will be used to respond to requests passed to your server. Each handler shares an identical signature to express route handlers.|required|

For detailed information about the configuration setup, follow this link

Add a start script to your package json

"scripts": {
  ...
  "appstrap": "appstrap start"
  ...
}

Launch!

npm run appstrap

This will start your server and assign a port. By default, 5000 is preferred, however you may override this by passing the -p 3000 argument into your startup script. If the port is already taken, Appstrap will automatically find an open port and bind to it instead. You may now access your server.

Don't forget about the management ui!

When your server is created via appstrap start, a mangement interface is also created for you. This interface is accessible via appstrap.localhost:{yourport} - with yourport being the same port that we bound your server to.

From here, you can toggle errors, simulate latency, and even load/unload presets. More information on the management ui can be found here

API reference

For api documentation follow this link.

Features

Error Mocking

Latency Mocking

Presets

Headless Mode