{"id":20037604,"url":"https://github.com/mrdulin/nodejs-microservice","last_synced_at":"2026-04-14T10:31:30.338Z","repository":{"id":98462316,"uuid":"125854050","full_name":"mrdulin/nodejs-microservice","owner":"mrdulin","description":"Node.js Microservices","archived":false,"fork":false,"pushed_at":"2018-03-22T09:59:14.000Z","size":442,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-03T22:40:28.130Z","etag":null,"topics":["chai","expressjs","keymetrics","mocha","nodejs","pm2","sinon"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrdulin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-19T12:28:35.000Z","updated_at":"2023-05-20T09:05:24.000Z","dependencies_parsed_at":"2023-06-01T20:30:55.791Z","dependency_job_id":null,"html_url":"https://github.com/mrdulin/nodejs-microservice","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mrdulin/nodejs-microservice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Fnodejs-microservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Fnodejs-microservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Fnodejs-microservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Fnodejs-microservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrdulin","download_url":"https://codeload.github.com/mrdulin/nodejs-microservice/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Fnodejs-microservice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31793212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chai","expressjs","keymetrics","mocha","nodejs","pm2","sinon"],"created_at":"2024-11-13T10:20:28.913Z","updated_at":"2026-04-14T10:31:30.320Z","avatar_url":"https://github.com/mrdulin.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nodejs-microservice\n\n使用`seneca`及相关插件, `express`, `node.js`，`mongodb`搭建微服务\n\n**环境:**\n\n* node: v8.4.0\n\n* npm: v5.3.0\n\n* pm2: 2.10.1\n\n* 其他依赖，见`package.json`\n\n**说明：**\n\n* `plugins`: `seneca`插件目录\n\n* `services`: `seneca`微服务，生产环境时，微服务是分布式的，本项目为方便测试，不同微服务使用相同 host(127.0.0.1)的不同端口，例如`productManager`微服务使用`http://127.0.0.1:3001`\n\n* `plugins/api.js`: 是 api 聚合插件，通过调用各个微服务（如`productManager`）用于给前端 ui 提供 api\n\n* `plugins/productManager.js`: 是一个具体的“商品管理服务”\n\n* `plugins/memoryLeak.js`：是一个内存溢出的微服务，用来测试 pm2 和 keymetrics 对应用监控的性能指标\n\n* `plugins/mockLotsRequest.sh`：用来模拟大量请求，使`memoryLeak.js`微服务内存溢出，观察 keymetrics 监控的内存指标\n\n**使用：**\n\n1.  以`productManager`服务为例, 通过`node services/productManager.js`等启动微服务，使用\n\n```bash\ncurl -d  '{\"area\": \"product\", \"action\": \"test\"}' http://localhost:3001/act\n```\n\n测试`productManager`服务是否正常\n\n2.  `npm start`启动`seneca`整合了`express.js`的应用\n\n3.  通过浏览器访问`http://localhost:3000/api/products`等获取数据，或者通过`curl`测试\n\n4.  `npm test`执行单元测试，执行完`npm test`会通过`npm`命令`post`钩子执行`npm posttest`检查覆盖率是否通过设定的指标（本项目设定代码行、分支、函数都为 75%）\n\n5.  `npm test:e2e`执行端到端测试\n\n6.  `pm2 start plugins/memoryLeak.js`启动应用，并使用`pm2 link secretKey publicKey [machine name]`将 pm2 的数据推送到 keymetrics\n\n7.  `npm run deploy-dev`，将应用部署到本地环境（部署目录，我的是`/home/elsa/development`），然后访问`http://localhost:3000/api/products`查看接口\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdulin%2Fnodejs-microservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrdulin%2Fnodejs-microservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdulin%2Fnodejs-microservice/lists"}