express-debug-panel

Background

Node.js is an open-source, server-side execution environment for JavaScript. It is built on Chrome's JavaScript runtime for easily building fast, scalable network applications. With JavaScript already the standard scripting language for web clients, it is very compelling to also use JavaScript for web application servers. In short, Node.js represents a “JavaScript everywhere” paradigm.

Node.js has the largest repository of open-source utilities in the world, collectively known as npm, the Node Package Manager. npm makes it easier for programmers to publish and share source code for useful pieces of Node.js functionality.

1200px-Npm-logo.svg.png

express-debug-panel

Finite Wisdom has contributed our first package to npm. It is called express-debug-panel and implements a panel containing useful debugging information, for use in Express.js applications. Let’s take a closer look at the functionality it provides.

The Debug Panel is initially displayed in collapsed form:

unopened.png

When you click on it, it opens in its default format:

opened-default-config.png

In this default format, it shows information for the following Express.js and Node.js objects:

You can also provide a custom format for the Debug Panel. In the following screenshot, we have suppressed the process object and replaced it with envconfig, and versions objects.

opened-custom-config.png

Demonstration

See a live demonstration of the Debug Panel at demo.finitewisdom.com.

Installation

To install the Debug Panel, use the following command:

carbon (14).png

Use

The Debug Panel works with all Express.js template engines. Here are the instructions for the three most popular engines:

Use with EJS

To add a Debug Panel to the /test route of your Express.js application that utilizes EJS templates, use the following code:

carbon (15).png

In your test.ejs view, include the following code:

carbon (17).png

Use with Pug

To add a Debug Panel to the /test route of your Express.js application that utilizes Pug templates, use the following code:

carbon (18).png

In your test.pug view, include the following code:

carbon (19).png

Use with Mustache

To add a Debug Panel to the /test route of your Express.js application that utilizes Mustache templates, use the following code:

carbon (20).png
 

In your test.mst view, include the following code:

carbon (21).png
 

Configuration

You can configure what is displayed in the Debug Panel by passing an options object as the 2nd argument to debugPanel.render. The options object takes the following form:

carbon (22).png

where:

  • name is the name of the tab within the Debug Panel

  • obj is the object to display

  • maxDepth is the maximum depth that will be displayed for nested objects

  • display indicates whether to include this tab within the Debug Panel

The default configuration for the Debug Panel is:

carbon (23).png

As an example, let's say that we wanted to configure the Debug Panel to suppress the process tab and replace it with three others:

  • env

  • config

  • versions

To do so, we would define an options object of the form:

Hello

We would then replace this code:

carbon (25).png

with this code:

carbon (26).png

Popularity

Since express-debug-panel was released in July 2020, it has been installed 441 times.

2021-03-26_12-00-25.png

By npm standards, this is paltry indeed. The most popular packages are installed millions of times per week!

Source: https://www.finitewisdom.com/people/joshua...