0.0.2 • Published 10 years ago

caper v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

Caper

Caper is a just-in-time HTTP server for simple dictionary resources.

From the command line:

bin/server example

Now you can use it:

curl -XPUT localhost:1337/weather/santa-monica -d'"70 degrees and sunny"'
curl localhost:1337/weather/santa-monica
'70 degrees and sunny'

Installation

npm install caper

Configuration

You can configure the host and port to run your Caper server and also the list of dictionary resources. Here's the example configuration used above:

resources: [ "people", "weather" ]
host: "localhost"
port: 1337

Use From Within Node

You can also run Caper programmatically:

caper = require "caper"
caper("example")

which will run a Caper server according to the example configuration.

Interface

  • GET {/collection} - Get all the items in the collection
  • GET {/collection}{/key} - Get the item in the collection with the given key
  • PUT {/collection}{/key} - Update the item in the collection with the given key
  • DELETE {/collection}{/key} - Delete the item in the collection with the given key
  • POST {/collection} - Create an item in the collection using a random key

Using Docker

Caper includes a Dockerfile so you can run a Caper server in a Docker container. Assuming you've cloned the Caper repo, you can run the following commands to get Caper running in a Docker container:

docker build -t caper .
docker run -p 49000:1337 --name caper -t caper:latest

Now test it out:

curl -XPUT localhost:1337/weather/santa-monica -d'"70 degrees and sunny"'
curl localhost:1337/weather/santa-monica
'70 degrees and sunny'