Seven-Steps for Designing a web API

2 בינואר 2014

This is the procedure described by Leonard Richardson in his book : RESTful Web APIs . The procedure consist of seven steps. Doing some preparatory workup front will help you choose a representation format and keep your profile as simpleas possible. 1. List all the pieces of information a client might want to get out of your API or putinto your API. These will become your semantic descriptors.Semantic descriptors tend to form hierarchies. A descriptor that refers to a realworldobject like a person will usually contain a number of more detailed, moreabstract descriptors like givenName. Group your descriptors...
no comments

Basic rules for building REST web APIs

We have a client-server Internet protocol, HTTP, which assigns very general meanings to different kinds of requests: GET, POST, PUT,and so on.We have the idea of hypermedia, which allows the server to tell the client which HTTP requests it might want to make next. This frees the client from having to know the shape of the API ahead of time.We have the idea of application semantics, which extend hypermedia controls with information about what specifically will happen, to application or resource state, if the client makes a certain HTTP request.And finally we have a whole lot of standards for...
no comments

How does “Exports” work in Node JS

1 בינואר 2014

If you wandered how does “NodeJS exports” works under the covers here in the answer. The trick is simple: wrap your function (object definition) with a wrapper function that accepts the exports object from the global scope. This makes exports global, allows you to attach your code to it and prevents your code from reaching the global scope. Code Snippet //wrapper function (function (exports, require, module, __filename, __dirname) {     //your code     var calculator = function() {         return {             add: function(a, b) { return a + b; }         };     };     exports.add = calculator; }); ...
no comments

How does “Exports” work in Node JS

If you wandered how does exports works under the covers here in the answer. The trick is simple: wrap your function (object definition) with a wrapper function that accepts the exports object from the global scope. This makes exports global, allows you to attach your code to it and prevents your code from reaching the global scope. 1: //wrapper function 2: (function (exports, require, module, __filename, __dirname) { 3: //your code 4: var calculator = function() { 5: ...
no comments