Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/onbjerg/micro-visualize
Visualizes requests and responses for services written with micro
https://github.com/onbjerg/micro-visualize
developer-tools micro visualizes-requests zeit
Last synced: about 2 months ago
JSON representation
Visualizes requests and responses for services written with micro
- Host: GitHub
- URL: https://github.com/onbjerg/micro-visualize
- Owner: onbjerg
- Archived: true
- Created: 2017-01-22T11:00:53.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T01:14:58.000Z (over 4 years ago)
- Last Synced: 2024-08-09T21:09:00.805Z (5 months ago)
- Topics: developer-tools, micro, visualizes-requests, zeit
- Language: JavaScript
- Homepage:
- Size: 48.8 KB
- Stars: 55
- Watchers: 4
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-micro - micro-visualize - Development tool that visualizes requests and responses for services written with Micro. (Development Tools / Utilities)
README
# `micro-visualize` [![NPM](https://img.shields.io/npm/v/micro-visualize.svg?style=flat)](https://www.npmjs.org/package/micro-visualize) [![travis-ci](https://travis-ci.org/onbjerg/micro-visualize.svg?branch=master)](https://travis-ci.org/onbjerg/micro-visualize) [![Greenkeeper](https://badges.greenkeeper.io/onbjerg/micro-visualize.svg)](https://greenkeeper.io/)
Visualizes requests and responses for services written with [`micro`](https://github.com/zeit/micro).
**Screenshot**
---
## Installation
```sh
npm install --save micro-visualize
```Or even better
```sh
yarn add micro-visualize
```## Import and Usage Example
```js
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Async function, your normal `micro` logic.
- `log` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** An optional log level (default: `dev`)**Examples**
```js
const visualize = require('micro-visualize')module.exports = visualize(async function (req, res) {
return 'Hello, world!'
})
``````js
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**.
## Credits
Thanks to @rickharrison for his [excellent PR](https://github.com/zeit/micro/pull/104) which this project was heavily based on.