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

restify-echo

v1.3.0

Published

A simple restify echo server for tests

Downloads

3

Readme

restify-echo

A simple echo server made with restify to serve every url you request. It catches all urls and sends back headers, body and metadata in JSON format. It allows you to change response statusCode and delay response with querystring parameters.

It has a simple ngrok tunnels support built-in.

Installation

        [sudo] npm install [-g] restify-echo

Usage

        Usage: 
        restify-echo [OPTIONS]
        
        Options:
          -c, --config     config file
          -n, --name       server name
          -p, --port       port to listen
          --ng, --ngrok    start an ngrok tunnel
          -s, --subdomain  ngrok subdomain (only if you provide a token)
          -t, --token      ngrok auth token
          -h, --help       Show help
        
        Examples:
          restify-echo -p 4000    starts the server in port 3000
          restify-echo --ngrok    starts a server with a tunnel available to everyone through internet
                                  
        

Once you've started the server. Send requests to http://localhost:3000/any/path/you/like?with=any&parameter=imaginable with the client you prefer a browser, curl, Postman or httpie. You can make GET|POST|PUT|DELETE request.

Querystring parameters

  • statusCode header status code to set in the response.
  • delay amount of milliseconds to delay the response.
  • throw type of restify error to throw. (ex: BadRequest, InternalError, etc)
  • msg when throw parameter is present, the error message to use.
  • json send the response body you want to receive in the response.
  • meta boolean to get a full response or only the body payload. Defaults to true.

Global vs Local install

If you install it as a local dependency start the command like this:

$> ./node_modules/.bin/restify-echo 

Ngrok support

Ngrok is a wonderful tool during development. It provides you a public url with a tunnel directly to your machine, so you can share active development with anyone.

If you use ngrok options it would also start a server on port 4040 where you can inspect all request made through the public url. By default ngrok will give you a random subdomain name, you can only change it if you signup and get an authtoken (free).

Config file

You can use a custom config file to setup your echo server. Check the config_example.js included or create one like this:

// my_config.js file

var custom_name = 'my-echo-server';

module.exports = {
  name: custom_name,
  port: 5000,
  bunyan: {
    name: custom_name,
    stream: process.stdout,
    level: 'info'
  },
  ngrok: {
    enabled: false,
    authtoken: '<your-ngrok-authtoken>',
    subdomain: custom_name
  }
};

And use it on execution:

$>  restify-echo -c my_config.js

TODO

  • Allow also a secure server
  • throw in some tests