{"id":18739019,"url":"https://github.com/gaubee/tsq","last_synced_at":"2025-11-18T12:30:13.699Z","repository":{"id":149112562,"uuid":"113927251","full_name":"Gaubee/tsq","owner":"Gaubee","description":"The next generation service framework is based on TypeScript","archived":false,"fork":false,"pushed_at":"2017-12-23T13:37:11.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T17:44:43.383Z","etag":null,"topics":["dependency-injection","microservice","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gaubee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-12-12T01:20:37.000Z","updated_at":"2021-12-18T09:35:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"4991ec9c-30f5-4f1b-8a8a-fa818592b009","html_url":"https://github.com/Gaubee/tsq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gaubee%2Ftsq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gaubee%2Ftsq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gaubee%2Ftsq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gaubee%2Ftsq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gaubee","download_url":"https://codeload.github.com/Gaubee/tsq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239616176,"owners_count":19668999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["dependency-injection","microservice","typescript"],"created_at":"2024-11-07T15:32:26.436Z","updated_at":"2025-11-18T12:30:13.639Z","avatar_url":"https://github.com/Gaubee.png","language":"TypeScript","readme":"# TSQ\n\n这是一个实验性的框架，使用了一些实验性的API。\n但很多概念还是有待商榷的。不过可以通过做减法来使用那些稳定的概念。\n\n**重度依赖TypeScript，目的是为了实现Angular一样的依赖注入。**\n\n## 为什么要用TypeScript\n\n在团队开发中，有一个不可避免的沟通成本。API调用是否正确？API破坏性更改引起的涟漪效应是否有全部解决？\n使用TypeScript的强类型约束与编译，可以用来解决这些问题。\n\n## 为什么要做依赖注入\n\n在微服务开发中。如若直接写RPC的调用，TypeScript的强类型约束无法直接在两个代码库之间进行推断。\n使用依赖注入的话，开发者**不需要关心RPC的调用**，靠着TypeScript的代码智能提示与类型检测，能写出安全的数据传输。\n使得代码完全与框架脱离关系。\n\n\u003c!-- ![image](https://user-images.githubusercontent.com/2151644/34319862-325cbde2-e827-11e7-99d6-60f7f39518f1.png) --\u003e\n如下代码：\n[B.service.ts](https://github.com/Gaubee/tsq/blob/7d896ff4c8d429b730ea2ca862cc63996eeb6102/test/B.service.ts)\n```ts\nexport class B {\n\tconstructor(public a: A) { }\n\n\tasync callA(name: string) {\n\t\treturn await this.a.sayHi(name);\n\t}\n\n\tadd(a: number, b: number) {\n\t\treturn this.a.add(a, b);\n\t}\n}\n```\nB模块依赖与A模块，在调用A模块的时候，可以以最原始的方式去调用A模块的实例的方法，异步方法，甚至是同步方法，而这A模块的服务运行在另外一个进程中，可同时供养于其它服务。\n\n## DEMO\n\n建议安装[ts-node](https://www.npmjs.com/package/ts-node)\n\n### 第一步： 启动中央服务\n\n```shell\nts-node test/center.service.ts\n```\n\n### 第二步： 启动A服务\n\n```shell\nts-node test/A.service.ts\n```\n\n### 第三步： 启动B服务\n\n```shell\nts-node test/B.service.ts\n```\n\n\u003e PS: 以上三步可以以任意的顺序启动。互相依赖的服务在有一端断开后都会自动重连。\n\n### 第四部：打开浏览器进行访问测试\n\n* **测试异步调用** https://localhost:8443/qaq/hi?name=gaubee\n* **测试同步调用** https://localhost:8443/qaq/add/1/2.2","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaubee%2Ftsq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaubee%2Ftsq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaubee%2Ftsq/lists"}