An analysis of Node's role in building hypermedia apis

  • 2020-03-30 03:37:48
  • OfStack

Whether it is hypermedia or hypertext, the transport 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 the Multipurpose Internet Mail Extensions. MIME is an Internet standard, which was first applied to the E-mail system, and then its definition was gradually applied to the Internet. With MIME specifying the type of media, the client browser knows exactly what to do with that type of media.

Node. js is a library built based on Google V8 JavaScript engine, which is mainly used for convenient and fast construction of scalable network applications. Node.js is event-driven. It takes full advantage of JavaScript's closure feature and event handling mechanism, and USES a non-blocking I/O model, making it ideal for data-intensive real-time applications. Node.js implements similar functionality to Apache HTTP Server, enabling it to build highly concurrent javascript-based Web applications. Node.js enables front-end and back-end development to use the same programming language, JavaScript.

REST Web services can be tailored to the HTTP protocol, which USES uris to identify unique network resources and verbs like GET, POST, PUT, DELETE to manipulate resources. REST Web services are obviously more concise and efficient than SOAP Web services, because they do 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 to use depends on the requirements of the project.

Node.js provides HTTP manipulation capabilities that can be used on the client or server side. The biggest advantage of node. js is that it has a large third-party library, and in terms of RESTful Web Services, there are also multiple libraries that can simplify our development efforts. Such as:

1) node - restify

Homepage: (link: https://github.com/mcavage/node-restify)

Restify is a streamlined, express-like, node. js library for building RESTful apis.

Installation:


$ npm install restify

2) node - restful

Homepage: (link: https://github.com/baugarten/node-restful)

Node-restful is an encapsulation of the Express library, and it's great for creating restful apis.

Installation:


npm install node-restful

There are many third-party libraries not to mention. In addition, we can build RESTful apis directly from the core library of node. js, or from the Express library. There are many ways to achieve your goal.

There are few books on hypermedia, and therefore even fewer dedicated to building hypermedia apis. Hypermedia is also a network resource and can be defined in terms of uris as well, so node. js is easy to implement a hypermedia RESTful API.


Related articles: