Skip to content

codependentfc/week8hapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hapi Routes

REST

The idea this week is to build a RESTful api. This keeps your endpoint URIs simple by making use the the 'verbs' the http methods (GET,POST,PUT,DELETE) provide.

For enlightenment and examples, please read this excellent articlee.

One thing worth noting, (and covered in the article above), is how to work around the inability of plain html to issue PUT and DELETE requests. If you want to do a 'real' rest api, js/jQuery will let you issue PUT/DELETE requests.

One way of doing this is to define in the API the actual call you want to use to replace POST:

POST: /user/1?method=put POST: /user/1?method=delete The API can then convert the POST call into the appropriate method, and funnel it into the same route.

See server.js for some fictional routes describing a basic blog.

Hapi

Nelson's excellent resource should get you up and running.

For further information see the API docs, and the hapi tutorials.

Instructions

  1. Clone this repo

  2. run npm install

  3. run node server.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published