Practical Node.js (2018版) 第8章:Building Node.js REST API Servers


Building Node.js REST API Servers with Express.js and Hapi

Modern-day web developers use an architecture consisting of a thick client and a a thin back-end layer。如AngularJS,ReactJs,VueJS。用来建立厚厚的client。

另一方面,他们使用REST APIs建立thin back-end layer。

 a representational state transfer (REST) web application programing interface (API) service。

这种结构,被称为厚客户端或者SPA单页面程序,变得越来越流行。因为它们有以下优势:

  • SPA更快,因为它们渲染网页元素在浏览器内,无需总是从服务器取HTML.
  • bandwidth更小,因为一旦它加载,大多数的页面布局位置相同,所以浏览器只需使用JSON格式的数据来改变网页的元素。
  • 相同的后端REST API可以服务多客户apps/consumers, web app是其中之一。
  • 不理解??:
  • There is a separation of concerns,i.e.,the clients can be replaced without compromising the integrity of the core business logic,and vice versa.
  • UI/UX难以测试,尤其是事件驱动,单页面程序,这有一个增加的跨浏览器测试的复杂程度。但是,分离的业务逻辑进入back-end REST API,这个逻辑变得容易测试:在unit和functional testing。

因此,大多数新程序接受使用REST API和Clients方法,即使开始只有一个客户。

 

使用Node创建REST API非常容易。

本章包括以下内容

相关文章

这篇文章主要介绍“基于nodejs的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...