Lately I have been resurecting an old project of mine - now called Resourceserver.
It is a simple, in-memory, resource-oriented http server, designed to be used during testing and development of rich-client web apps.
Here is the README:
Resourceserver
TODO: Implement a persistent version (probably using redis).
Implements an in-memory resource oriented HTTP server, provding 5 basic operations (shown in curl_tests.sh)
POST /:collection
Create a new resource.
curl -vX POST http://localhost:3002/people -H 'content-type: application/json' -d '{"name": "Liam", "age": 29}'
{
"name": "Liam",
"age": 29,
"id": 2
}
curl -vX POST http://localhost:3002/people -H 'content-type: application/json' -d '{"name": "Noah", "age": 1}'
{
"name": "Noah",
"age": 1,
"id": 2
}
GET /:collection/:id
Retrieve the :collection
resource with id :id
.
curl -v http://localhost:3002/people/1
{
"name": "Liam",
"age": 29,
"id": 1
}
GET /:collection
Retrieve an array of all :collection
resources.
curl -v http://localhost:3002/people
[
{
"name": "Liam",
"age": 29,
"id": 1
},
{
"name": "Noah",
"age": 1,
"id": 2
}
]
PUT /:collection/:id
Override the :collection
resource with id :id
.
curl -vX PUT http://localhost:3002/people/1 -H 'content-type: application/json' -d '{"name": "LiamO", "age": 30}'
{
"name": "LiamO",
"age": 30,
"id": "1"
}
DELETE /:collection/:id
Delete the :collection
resource with id :id
.
curl -vX DELETE http://localhost:3002/people/1
It uses the CORS headers to allow cross-origin requests.
Usage
Clone the repository
Install node.js
Install the dependencies with
npm install
Start the server with
npm start
[Optional] Run tests with
cd test && ./curl_tests.sh