Restify

 

 

 

 

March 11, 2015

{C4}

Victor Lee

 

Contents

I.  REST

     a) What is it?

     b) Fundamentals

 

II. RESTful API's

     a) What is it?

​     b) Frameworks

 

III.  Restify

     a) What is it?

     b) Features

 

IV.  Example

     a) Restify API

What is REST?

 

(Representational State Transfer)

 

It is an architecture style of the web built on certain principles using current web fundamentals

REST consists of two main concepts:

client

server

Request

Response

  • Resource:  Any object associated with data or identified with a URI
  • Representation:  The method to display the resouce

Emphasizes that interactions between client and server is enhanced by a limited number operations (verbs) which avoids ambiguity.

  • Everything is a resource (files, image, videos, etc.)
  • Unique identifier (all resources)
  • Uses simple and uniform interfaces (Methods + Resource Names = Uniform Interfaces) 
  • Everything is a representation (XML, JSON)
  • Stateless - every request should be independent

What are the REST fundamentals?

Utility

  • Build Utilities (i.e. gulp, grunt, listen to file system changes, live reload, etc.)
  • Web Server - build scalable web applications, data driven real time applications

Other Frameworks

What are RESTful API's?

When web services use REST architecture, they are called RESTful API's.  Often used in mobile applications, social networking web sites, automated business processes.

  • hapi.js
  • Geddy
  • Koa
  • total.js
  • flatiron
  • socketstream
  • sails.js

Real World REST API's

Examples

  • Read and write Twitter data
  • Author a new Tweet
  • Read author profile and follower data
  • The REST API identifies Twitter applications and users using OAuth
  • responses are available in JSON.

Twitter's REST API

Created by Mark Cavage

 

Resitfy is a node.js module focused on building REST API applications.  A condensed version of Express that doesn't include "non RESTful" items like a templating or rendering engine

Restify = Express - non RESTful stuff

What is Restify?

 

  • Borrows heavily on Express, which helps to build on familiarity of its use
  • Let’s you build “strict” API services that are maintainable and observable
  • Comes with automatic DTrace support for all your handlers (troubleshooting application problems in real time)
  • Absolute control over interactions with HTTP and full observability into the latency and characteristics of applications
  • Doesn’t have unnecessary functionality like templating and rendering
  • Built in throttling (ability to limit the amount of data that can be sent or received per unit time)
  • Built in SPDY support (speedy) helps to reduce web page load time by reducing web page load latency and improving web security

 

 

Features

 

  • http://mcavage.me/node-restify/
  • http://code.tutsplus.com/tutorials/restful-api-design-with-nodejs-restify--cms-22637
  • https://strongloop.com/strongblog/compare-express-restify-hapi-loopback/
  • http://searchsoa.techtarget.com/definition/REST
  • http://blog.newrelic.com/2014/08/15/node-js-frameworks-hapi-js-restify-geddy/
  • http://codecondo.com/7-minimal-node-js-web-frameworks/
  • http://synthmedia.co.uk/blog/basic-nodejs-api-with-restify-and-save#.VQCBrWTF-h0

 

 

Resources

deck

By vic_lee

deck

  • 662