JSPM

express-var-dump

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q25332F
  • License MIT

Express view helper that displays all kinds of data (post, query, string, params, cookies, session).

Package Exports

  • express-var-dump

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (express-var-dump) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

express-var-dump

The Express version of PHP's var_dump(). It lets you output information in JSON format regarding cookies, session data, query params, route params, post data and request headers by default.

install

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

npm install express-var-dump

usage

First add the view helper to your app:

// app.js
const { addVarDumpViewHelper } = require('express-var-dump');
const app = require('express')();

// ..define express middleware && other stuff before..

app.use(addVarDumpViewHelper);

// ..define express routing after..

Then in your view call varDump() (using ejs templating engine below):

<!-- views/index.ejs -->
<html>
  <body>
    <%- varDump() %>
  </body>
</html>

Output:

screenshot

advanced usage

varDump(arrayOfProperties, object): html

You can also use varDump directly to generate prettified JSON data to HTML code for any object (in Express it defaults to the request object and the properties detailed in the description).

const { varDump } = require('express-var-dump');
const packageData = require('./package.json');

console.log(varDump(['name', 'version', 'author', 'dependencies'], packageData));
// outputs HTML code generated with `pretty-print-json`

That allows you to use the module with other Node.js web apps that don't use Express.

license

MIT