Visualizes requests and responses for services written with micro
.
Screenshot
npm install --save micro-visualize
Or even better
yarn add micro-visualize
const visualize = require('micro-visualize')
module.exports = visualize(async function (req, res) {
return 'Hello, world!'
})
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 normalmicro
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.
Thanks to @rickharrison for his excellent PR which this project was heavily based on.