简体   繁体   English

Hyperledger-Composer:为什么使用 Node.js 而不是 Angular?

[英]Hyperledger-Composer: Why use Node.js instead of Angular?

When developing Hyperledger Composer applications, there is a typical solution architecture that looks as follows:在开发 Hyperledger Composer 应用程序时,有一个典型的解决方案架构,如下所示:

在此处输入图片说明

According to the docs there is an alternative solution architecture that uses Node.js (seehttps://hyperledger.github.io/composer/latest/applications/node ):根据文档,有一种使用 Node.js 的替代解决方案架构(参见https://hyperledger.github.io/composer/latest/applications/node ):

在此处输入图片说明

Why would one choose the second architecture (with node.js), given that this involves one step more: not only do you have to write a node.js application but you then also have to develop a front-end for this node.js application (so 2 steps).为什么会选择第二种架构(使用 node.js),因为这涉及多一步:您不仅必须编写 node.js 应用程序,而且还必须为此 node.js 开发前端应用程序(所以 2 个步骤)。

In the case of the first architecture, one only has to create an Angular application (because the REST server just needs to be started but the REST API is generated automatically by the framework) and is done (so there is only 1 step).在第一种架构的情况下,只需要创建一个 Angular 应用程序(因为 REST 服务器只需要启动,而 REST API 是由框架自动生成的)并完成(因此只有 1 个步骤)。

Are there any arguments in favour of using Node.js I'm not seeing?是否有任何支持使用 Node.js 的论据我没有看到?

The case for node.js is only if you don't want to create a user interface, or, if you wish to create wrappers around the existing hyperledger endpoints that reformat the consumption. node.js 仅适用于您不想创建用户界面的情况,或者,如果您希望围绕重新格式化消费的现有超级账本端点创建包装器。 A case could be that every day at 5pm you want to post an update to an asset based on what has changed in a different database somewhere... in this case you couldn't use Angular directly.一种情况可能是,每天下午 5 点,您想根据某处不同数据库中的更改发布对资产的更新……在这种情况下,您无法直接使用 Angular。

It's also important to note Angular is exclusively client side, Node.js is exclusively server side, and you cannot serve an API with Angular.同样重要的是要注意 Angular 是唯一的客户端,Node.js 是唯一的服务器端,你不能用 Angular 提供 API。

Separation of front end and back end is common practice now and is suggested for applications that contain both.前端和后端的分离现在是常见的做法,建议包含两者的应用程序。 Here's an article on it: https://quickleft.com/blog/six-reasons-we-split-front-end-and-back-end-code-into-two-git-repositories-working-with-github-repositories/这是一篇关于它的文章: https : //quickleft.com/blog/six-reasons-we-split-front-end-and-back-end-code-into-two-git-repositories-working-with-github-存储库/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM