-
Add validation
-
Add pre/post hooks
Implements an in-memory (or persistent via redis) resource oriented HTTP server, provding 5 basic operations (shown in curl_tests.sh). Edit redis connection config in config.coffee.
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
}
Retrieve the :collection
resource with id :id
.
curl -v http://localhost:3002/people/1
{
"name": "Liam",
"age": 29,
"id": 1
}
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
}
]
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 the :collection
resource with id :id
.
curl -vX DELETE http://localhost:3002/people/1
It uses the CORS headers to allow cross-origin requests.
-
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