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

expressivejs

v1.1.3

Published

End to end server route tracking for express.js applications

Downloads

12

Readme

Expressive.js

Expressive is a developer tool that tracks and visualizes server routes in Express applications. Useful for debugging and teaching alike, Expressive enables developers to send client requests to their Express server, and then render a dynamic and comprehensive visualization of server state throughout the lifespan of each request -- all from the command line.

Install

$ npm install expressivejs --save-dev

Setup

1) Modify Express server files

Replace all instances of require('express') with require('expressive-proxy'). This will enable Expressive to progressively document the state of client requests and server responses.

2) Create a configuration file

This file should be called expressive.config.js and be located in your application's root directory.

From the command line

Enter $ xpr-init from your application's root directory to create the basic shell of your expressive.config.js file.

Manually

Here is what your expressive.config.js file should look like:

module.exports = {
  // Required Keys
  entry: './server.js',          // Relative path to your Express server file.
  outputDir: '/',                // Should always be set to '/'.
  host: 'http://localhost:3000', // Server network host and port.
  requests: [...reqObj],         // Array of HTTP requests. Specifications below.

  // Optional Keys
  silentServer: false,   // Hide server's console logs?  Default: false.
  wipeCookies: false,    // Wipe cookies after each request?  Default: false.
  abandonRequest: 3      // Seconds to wait before abandoning a request.  Default: 3.
} 

Here is what the objects in the requests array should look like:

{
  // Required Keys
  method: 'GET',  // HTTP request method
  route: '/',     // HTTP request route

  // Optional Keys: See below
}
Optional Keys:

When testing server routes, Expressive passes each object in the requests array as the options parameter in the request(options, callback) function of the Request module. Consult the Request documentation for details on adding further request specifications, such as headers or bodies. DO NOT modify the uri||url or baseUrl keys.

Testing Server Routes

Command Line Scripts

$ xpr-test: Test your server routes. Sends http requests to your Express server as specified in your expressive.config.js file. This will create an expressive.json file in which information on request and response states is stored. If the file already exists from previous tests, it will be overwritten.

$ xpr-build: Bundle data from the expressive.json file created using the xpr-test command for use in rendering a visualization of your server routes.

$ xpr-display: Render a visualization of your server routes based on the data bundled from the xpr-test command.

$ xpr: Test your server routes, then bundle the collected data, and then render a visualization. Equivalent to running xpr-test followed by xpr-build followed by xpr-display.

Important

Do not alter res.locals._XPR

Any server middleware that alters res.locals._XPR will interfere with Expressive's functionality. Expressive tracks the state of client requests and server responses by storing information at the _XPR key within the locals property of the server response body.

On relocating expressive.config.js

When relocating your Expressive configuration file, be sure to alter its relative path to your server file accordingly.

Expressive is not for use in production

Before running your application for non-testing purposes, be sure to change all instances of require('expressive-proxy') in your server files back to require('express').

Expressive is in active development.

Follow our GitHub repo for updates.

Contributors

Glenn Alexander | Ryan Fowlkes Smith | Kangseon Cho | Mary Snow