开源Nodejs微服务项目推荐:micro

自闭症网瘾萝莉.ら 提交于 2020-04-07 06:36:45

https://github.com/zeithq/micro

Micro — Async HTTP microservices

Features

  • Easy. Designed for usage with async and await (more)
  • Fast. Ultra high performance (even JSON parsing is opt-in).
  • Micro. The whole project is ~100 lines of code.
  • Agile. Super easy deployment and containerization.
  • Simple. Oriented for single purpose modules (function).
  • Explicit. No middleware. Modules declare all dependencies.
  • Standard. Just HTTP!

Example

The following example sleep.js will wait before responding (without blocking!)

import { send } from 'micro';
import sleep from 'then-sleep';
export default async function (req, res) {
  await sleep(500);
  send(res, 200, 'Ready!');
}

To run the microservice on port 3000, use the micro command:

$ micro -p 3000 sleep.js

点评

  • 技术栈比较潮,es7的async/await,性能会很好
  • 遵循node的小而美哲学
  • 文档,测试,代码都比较规范

在微服务架构的潮流里,是一个不错的选择

全文完

欢迎关注我的公众号【node全栈】

如果想参与评论,请点击原文链接,进入国内最专业的cnode论坛

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!