Whether it is hypermedia or hypertext, the transmission protocol used is HTTP, which means that hypermedia can be accepted by all browsers. We use MIME to describe the type of hypermedia. MIME is Multipurpose Internet Mail Extensions, a multipurpose Internet mail extension type. MIME is an Internet standard. It was first applied to the email system, and later its definition was gradually applied to the Internet field. By specifying the type of media with MIME, the client browser will know clearly how to deal with this type of media.
Node.js is a library built on Google V8 JavaScript engine, which is mainly used to facilitate and quickly build scalable network applications. Node.js is event-driven. It makes full use of JavaScript's closure characteristics and event processing mechanism, and adopts a non-blocking I/O model, which is very suitable for data-intensive real-time applications. Node.js implements similar functions to Apache HTTP Server, making it possible to build high-concurrent web applications based on JavaScript. Node.js enables front-end and back-end development to use the same programming language - JavaScript.
REST Web service can be said to be tailor-made for the HTTP protocol. URI is used in the HTTP protocol to identify unique network resources and use verbs such as GET, POST, PUT, DELETE to operate resources. REST Web service is obviously more concise and efficient than SOAP Web service because it does not require additional encapsulation protocols and remote procedure calls.
As for the representation of the resource, it can be HTML5, XML data format, JSON data format, or binary Protobuf format. Which data format is used depends on the project's requirements.
Node.js provides HTTP manipulation capabilities and can be used on both the client and the server side. The biggest advantage of Node.js is that it has a huge third-party library. In terms of RESTful Web Services, there are also multiple libraries that can simplify our development work. for example:
1) node-restify
Home page: https://github.com/mcavage/node-restify
restify is a thin, similar to Express library, Node.js library for building RESTful APIs.
Install:
$ npm install restify
2) node-restful
Home page: https://github.com/baugarten/node-restful
node-restful is an encapsulation of the Express library, which is very suitable for creating RESTful APIs.
Install:
npm install node-restful
There are many third-party libraries that I won't list them one by one. In addition, we can directly use the core library of Node.js to build the RESTful API, or use the Express library to build the RESTful API. There are many ways to achieve the goal.
There are few books on hypermedia, so there are even fewer books that specifically discuss how to build hypermedia APIs. Hypermedia is also a network resource and can also be defined by URIs. Therefore, it is easy to implement the RESTful API of hypermedia in Node.js.
I have to say that the book "Building Hypermedia API with HTML5 and Node" is translated too stiffly and it feels uncomfortable to read. However, this book itself is still valuable because the requirement of implementing a hypermedia RESTful API is very common and can be said to be one of the essential skills for web developers. Reading repeatedly and understanding its connotation is my little suggestion for readers of this book.