npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

request-watcher-server

v1.5.3

Published

an app for [request-watcher](https://github.com/lisiur/request-watcher)

Downloads

51

Readme

request-watcher-webapp

an app for request-watcher

Install

$ npm install -g request-watcher-server
$ npm install -D request-watcher

Usage

Start Server

The server requires node v7.6.0 or higher for ES2015 and async function support

Once you globally installed the request-watcher-server, you will get a global cmd request-watcher-server and also rws for short.

And then you can use the following cmd:

$ rws [-a 0.0.0.0] [-p 2333]

default address is 0.0.0.0:2333 you can use rws -h to get more help

Watch Request

const watcher = require('request-watcher')
const watcherParams = {
  username: 'username',
  appname: 'appname',
  labels: [],
}

// e.g.
// before send a request, emit the request to request-watcher-server
const { emitReq, emitRes } = watcher(watcherParams)
const requestParams = { url, params, headers, method: 'POST' }
emitReq(requestParams)
axios.post(url, params, headers)
  .then(res => {
    // after get the response, emit the response to request-watcher-server
    const { status, data, headers } = res
    const responseParams = { status, data, headers }
    emitRes(responseParams)
    // your biz code bellow
  })
  .catch(err => {
  })

Note that each time you watch a request, you need to use the watcher function to regenerate the matching emitReq and emitRes

watcherParams

watcherParams is an Object Containing the following properties

Args | Type | Description ------------- | ------------- | -------- origin | String (optional) | watcher origin username | String (required) | one of the request markers appname | String (required) | one of the request markers labels | [String] (optional) | add extra label to request to differentiate

requestParams

requestParams is an Object Containing the following properties

Args | Type | Description ------------------|----------------------|--------- url | String (optional) | request url method | String (optional) | request method headers | Object (optional) | request headers params | Object (optional) | request params in body

responseParams

responseParams is an Object Containing the following properties

Args | Type | Description ------------------|----------------------|--------- status | Integer (optional) | response status headers | Object (optional) | response headers data | Object (optional) | response data

Watch Logger

You can just emit a log to the server, like bellow:

const { emitLog } = watcher(watcherParams)

const loggerParams = { title: 'logger', content: 'this is a log' }
emitLog(loggerParams)

loggerParams

loggerParams is an Object Containing the following properties

Args | Type | Description ------------------|----------------------|--------- title | String (optional) | logger title content | Any (optional) | logger content

Global Config

You can use watcher.global to define global params, and thus you can just use watcher() without passing params.

watcher.global.origin = 'http://127.0.0.1:8080' // default is 'http://0.0.0.0:2333'
watcher.global.username = 'lisiur' // default is 'username'
watcher.global.appname = 'test-app' // default is 'appname'

const { emitReq, emitRes } = watcher()
const { emitLog } = watcher()

Plugins

We support plugin to simplify the configs. And now we have those plugins:

Plugin Usage

Using axios for example:

const watcher = require('request-watcher')
watcher.use(require('request-watcher-axios'))

And then, you can just focus on your biz code without inserting redundant code before or after the ajaxing code.

Eggs

  • Clicking the Console button outputs the data to the browser's console and obtains a global variable $it pointing to that data.

Example

Refer to this example

Enjoy! :)