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

rest-server-dummy

v1.0.14

Published

A dummyserver to develop and test rest clients

Downloads

14

Readme

The ultimate restify dummy server

If you are developing a REST-Client than you definitely need this mock server

Installation

npm install rest-server-dummy -g

What It Does for You

When you are dealing with remote REST API's as a developer of a client Application, than you should have something on your local machine that mocks the API.

rest-server-dummy is the tool you want to debug GET, POST PUT and DELETE calls in the easiest way. Here is the simple elegance of stupidity that just works. It will save you from a lot of trouble while you developing on your software.

How To Use It

After you have installed the Software, you should start the server:

node rest-server-dummy

The default server settings are:

| | | |:----------|----------:|
|PORT | 8080 |
|DIRECTORY | ./ |

Now you can work with the server in your application with the url

http://localhost:8080/some/great/file.json

in 1.0.3 you do not have to provide .json to the resouce

http://localhost:8080/some/great/file

will generate a file in the /some/great directory that called file.json

POST

Everytime you post a document to the server it will create a file in the DIRECTORY. If you are working with the default setting, and post /some/great/file.json, than a directory called "some" will be created in your current work directory. Inside that directory an other one named "great" is created and inside this a file named "file.json" stores the content from your POST Request.

To explain further examples, we asume at this point that you post a document that looks like this:

{
   "name": "james"
}

It is not very complex but you will know better what fits your needs and can build your own document.

PUT

A PUT will alter a document. For example we a document to the same address: some/great/file.json

{
   "gender": "male"
}

Than the result in the file will be merged to:

{
    "name": "james",
    "gender": "male"
}

GET

You can fetch posted documents, or you can copy mock .json files to the directory structure and fetch them with a GET Request.

A GET on some/great/file.json will return the same document:

{
    "name": "james",
    "gender": "male"
}

DELETE

If you request a DELETE method, the file, and the directories will be removed. A GET after a DELETE should produce a 404.

The directories will be removed when there is no other file only. Even a .response file will halt the removing process!

While deleting a resource no request file is produced.

The .request File

Every call will produce a extra file with the suffix .request If you are GET/POST/PUT a resourcece (for example: some/great/file.json), a file named some/great/file.request will be written. In this file your request headers are stored.

{
  "host": "localhost:8080",
  "accept": "*/*",
  "content-type": "application/x-www-form-urlencoded",
  "connection": "keep-alive",
  "user-agent": "YourApp/0.1",
  "accept-language": "en-us",
  "accept-encoding": "gzip, deflate",
  "content-length": "7"
}

This is very handy when you debugging your client. All headers are stored right beside the content.

Extra Options

Maybe you do not want the results in the working directory? No Problem, just start up the server with a DIRECTORY option and all files are stored there:

DIRECTORY=/tmp node rest-server-dummy

Mastering Your Calls

Debugging clients is hard. But not as hard as Haddekuche!

To fetch the document with additional headers, you can write a .response file with the same baseman as your resource and store some headers there. In our example a file named: some/great/file.response will be merged to the headers that are returned to your client.

{
  "foo": "bar"
}

That response file will produce a header like:

Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Server: rest-server-dummy
Access-Control-Expose-Headers: Api-Version, Request-Id, Response-Time
Api-Version: 1.0.0
Content-MD5: TGOyctqnSLSYozRZIPJyyQ==
Access-Control-Allow-Headers: Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Api-Version, Response-Time
Response-Time: 15
Date: Fri, 27 Feb 2015 16:31:56 GMT
Content-Length: 126
Connection: Keep-Alive
Request-Id: 25570e50-be9e-11e4-b5c2-235a2c2e6d6c
foo: bar

Questions

Ask us on Twitter @ausderTechnik

Spend a Satoshi

if you like this tool, spend a Satoshi to this address:

1DtvkCh28zqarTEUHtxs7gWtutsv2Cnf9d