0.0.6 • Published 9 years ago

superserver v0.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

Superserver NPM version Build Status Coverage Status Climate Status

a dummy REST server for testing HTTP client

DEMO

Installation

$ npm install superserver --global

CLI

Always returns by JSON.stringify the request object of requestListener. And add a summary of request: .originalUrl, .query,.body,.data.

$ superserver 8080
# Server running at http://localhost:8080/

$ curl http://localhost:8080/\?foo\=bar --data '{"baz":"beep"}' > request.json

request.json

{
  "headers": {
    "host": "localhost:8080",
    "user-agent": "curl/7.43.0",
    "accept": "*/*",
    "content-length": "14",
    "content-type": "application/x-www-form-urlencoded"
  },
  "url": "/?foo=bar",
  "method": "POST",
  "originalUrl": "http://localhost:8080/?foo=bar",
  "query": {
    "foo": "bar"
  },
  "body": "{\"baz\":\"beep\"}",
  "data": {
    "baz": "beep"
  }
  // ...
}

API

superserver.listen(port,callback)

superserver.close(callback)

Start the superserver on the specified port

import superserver from 'superserver'

const port= 59798
superserver.listen(port,()=>{
  console.log('Server running at http://localhost:%s/',port)
})

License

MIT

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago

0.0.0

9 years ago