Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.
/ micro-visualize Public archive

Visualizes requests and responses for services written with micro

Notifications You must be signed in to change notification settings

onbjerg/micro-visualize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

micro-visualize NPM travis-ci Greenkeeper

Visualizes requests and responses for services written with micro.

Screenshot


Installation

npm install --save micro-visualize

Or even better

yarn add micro-visualize

Import and Usage Example

const visualize = require('micro-visualize')

module.exports = visualize(async function (req, res) {
  return 'Hello, world!'
})

API

visualize

Visualize requests and responses for a given function. The function is a no-op if log is not dev.

Parameters

  • fn Function Async function, your normal micro logic.
  • log String An optional log level (default: dev)

Examples

const visualize = require('micro-visualize')

module.exports = visualize(async function (req, res) {
  return 'Hello, world!'
})
const visualize = require('micro-visualize')

// Will only visualize requests/responses if
// ``process.env.NODE_ENV`` is ``dev``
module.exports = visualize(async function (req, res) {
  return 'Hello, world!'
}, process.env.NODE_ENV)

Returns an async Function.

Credits

Thanks to @rickharrison for his excellent PR which this project was heavily based on.