caper
v0.0.2
Published
Just-in-time HTTP server for simple dictionary resources.
Downloads
7
Readme
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 collectionGET {/collection}{/key}
- Get the item in the collection with the given keyPUT {/collection}{/key}
- Update the item in the collection with the given keyDELETE {/collection}{/key}
- Delete the item in the collection with the given keyPOST {/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'