{"id":21317860,"url":"https://github.com/layotto/js-sdk","last_synced_at":"2025-07-12T02:32:55.415Z","repository":{"id":108417350,"uuid":"426560217","full_name":"layotto/js-sdk","owner":"layotto","description":"js sdk for layotto","archived":false,"fork":false,"pushed_at":"2024-05-20T08:25:09.000Z","size":194,"stargazers_count":3,"open_issues_count":6,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-21T09:05:59.472Z","etag":null,"topics":["dapr","grpc","layotto","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/layotto.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","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":"2021-11-10T09:27:28.000Z","updated_at":"2024-05-20T08:25:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"80473618-b607-49c1-8e7e-448f9db3fbce","html_url":"https://github.com/layotto/js-sdk","commit_stats":{"total_commits":27,"total_committers":6,"mean_commits":4.5,"dds":"0.33333333333333337","last_synced_commit":"6cb6d9a6faeddac752ad9f7ed98172bb4c7b2d8c"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layotto%2Fjs-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layotto%2Fjs-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layotto%2Fjs-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layotto%2Fjs-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/layotto","download_url":"https://codeload.github.com/layotto/js-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225787466,"owners_count":17524108,"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":["dapr","grpc","layotto","nodejs"],"created_at":"2024-11-21T19:09:13.976Z","updated_at":"2024-11-21T19:09:14.913Z","avatar_url":"https://github.com/layotto.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Layotto Node.js SDK\n\nThe Layotto Node.js SDK to build your application.\n\n[![NPM version](https://img.shields.io/npm/v/layotto.svg?style=flat-square)](https://npmjs.org/package/layotto)\n[![NPM quality](https://npm.packagequality.com/shield/layotto.svg?style=flat-square)](https://packagequality.com/#?package=layotto)\n[![NPM download](https://img.shields.io/npm/dm/layotto.svg?style=flat-square)](https://npmjs.org/package/layotto)\n\n[![Node.js CI](https://github.com/layotto/js-sdk/actions/workflows/nodejs.yml/badge.svg)](https://github.com/layotto/js-sdk/actions/workflows/nodejs.yml)\n[![Test coverage](https://img.shields.io/codecov/c/github/layotto/js-sdk.svg?style=flat-square)](https://codecov.io/gh/layotto/js-sdk)\n[![Known Vulnerabilities](https://snyk.io/test/npm/layotto/badge.svg?style=flat-square)](https://snyk.io/test/npm/layotto)\n\n## Clone\n\n```bash\ngit clone --recurse-submodules git@github.com:layotto/js-sdk.git\n```\n\nIf forgot to add `--recurse-submodules`, you can run `git submodule update --init --recursive` to clone the submodules.\n\nMore git submodule commands, please refer to [Git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules).\n\n## Usage\n\n### State\n\n`demo/state.ts`\n\n```ts\nimport { Client } from 'layotto';\n\nconst storeName = 'redis';\nconst key = 'foo-js-sdk';\nconst value = `bar, from js-sdk, ${Date()}`;\n\nawait client.state.save({\n  storeName, \n  states: { key, value },\n});\nconsole.log('saveState success, key: %j, value: %j', key, value);\n\nconst resValue = await client.state.get({ storeName, key });\nconsole.log('getState success, key: %j, value: %j, toString: %j',\n  key, resValue, Buffer.from(resValue).toString('utf8'));\n```\n\n## Development\n\n### Install dependencies\n\n```bash\nnpm install\n```\n\n### Generate gRPC files\n\nShould install [grpc-tools](https://github.com/grpc/grpc-node) first.\nMacOS M1 follow [this issue](https://github.com/grpc/grpc-node/issues/1405).\n\n```bash\nnpm run build:grpc\n```\n\n### Run Tests\n\n### step 1. Set up the environment\n\n- Running redis and etcd under Docker\n\n```bash\ndocker-compose up -d\n```\n\n- Start a echoserver for testing the rpc api\n\n```bash\nnode demo/rpc/http/server.js\n```\n\nIf you want to know more about this, check https://mosn.io/layotto/#/zh/start/rpc/helloworld\n\n- Start Layotto, see [How to run layotto](https://mosn.io/layotto/#/zh/start/state/start?id=%e7%ac%ac%e4%ba%8c%e6%ad%a5%ef%bc%9a%e8%bf%90%e8%a1%8clayotto)\n\n```bash\ncd layotto/cmd/layotto\ngo build\n\n./layotto start -c ../../../demo/config.json\n```\n\n### step 2: Run the tests\n\n- Then, run the test script by npm\n\n```bash\nnpm run test:unit\n```\n\nEnable trace debug log for grpc-js:\n\n```bash\nGRPC_TRACE=compression GRPC_VERBOSITY=debug GRPC_TRACE=all npm run test test/unit/client/Invoker.test.ts\n```\n\n## Reference\n\n- [Core concepts, architecture and lifecycle](https://grpc.io/docs/what-is-grpc/core-concepts/)\n- [Get Start with gRPC on Node.js](https://grpc.io/docs/languages/node/quickstart/)\n- [Node.js gRPC Library](https://grpc.github.io/grpc/node/)\n- [Understanding Streams in Node.js](https://nodesource.com/blog/understanding-streams-in-nodejs/)\n- [Go Proxy in China](https://learnku.com/go/wikis/38122)\n- [How to build a bi-directional streaming gRPC service with Node.js and Java](https://medium.com/@Mark.io/bi-directional-streaming-grpc-with-node-js-and-java-7cbe0f1e0693)\n\n## License\n\n[Apache License 2.0](LICENSE)\n\n\u003c!-- GITCONTRIBUTOR_START --\u003e\n\n## Contributors\n\n|[\u003cimg src=\"https://avatars.githubusercontent.com/u/156269?v=4\" width=\"100px;\"/\u003e\u003cbr/\u003e\u003csub\u003e\u003cb\u003efengmk2\u003c/b\u003e\u003c/sub\u003e](https://github.com/fengmk2)\u003cbr/\u003e|[\u003cimg src=\"https://avatars.githubusercontent.com/u/26001097?v=4\" width=\"100px;\"/\u003e\u003cbr/\u003e\u003csub\u003e\u003cb\u003eseeflood\u003c/b\u003e\u003c/sub\u003e](https://github.com/seeflood)\u003cbr/\u003e|[\u003cimg src=\"https://avatars.githubusercontent.com/u/68213475?v=4\" width=\"100px;\"/\u003e\u003cbr/\u003e\u003csub\u003e\u003cb\u003eLZHK1ng\u003c/b\u003e\u003c/sub\u003e](https://github.com/LZHK1ng)\u003cbr/\u003e|[\u003cimg src=\"https://avatars.githubusercontent.com/u/6897780?v=4\" width=\"100px;\"/\u003e\u003cbr/\u003e\u003csub\u003e\u003cb\u003ekillagu\u003c/b\u003e\u003c/sub\u003e](https://github.com/killagu)\u003cbr/\u003e|\n| :---: | :---: | :---: | :---: |\n\n\nThis project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Oct 13 2022 15:14:41 GMT+0800`.\n\n\u003c!-- GITCONTRIBUTOR_END --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flayotto%2Fjs-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flayotto%2Fjs-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flayotto%2Fjs-sdk/lists"}