/hapi-restful-api-example

An example of a restful api built using hapi.js

Primary LanguageJavaScriptMIT LicenseMIT

A Tasks API built using hapi v8.0

Build Status dependency Status devDependency Status

An example of a Restful API built using hapi.js v8.0 for storing a list of tasks.
Check out the demo.

Install

$ git clone git@github.com:rcorral/hapi-restful-api-example.git
$ cd hapi-restful-api-example
$ npm install

Run

$ node index.js

Using the API

Get tasks

$ curl -XGET http://localhost:8000/tasks

Get task by id

$ curl -XGET http://localhost:8000/tasks/{id}

Add tasks

$ curl -XPOST http://localhost:8000/tasks \
       -H 'Content-Type: application/json' \
       -d '{"task": "Play futbol."}'

Update task

$ curl -XPUT http://localhost:8000/tasks/{id} \
        -H 'Content-Type: application/json' \
        -d '{"task": "Play soccer."}'

Delete task

$ curl -XDELETE http://localhost:8000/tasks/{id}

Tests

$ npm test

License

MIT