{"id":17184187,"url":"https://github.com/xgheaven/nos-node-sdk","last_synced_at":"2025-07-30T21:37:36.510Z","repository":{"id":33151515,"uuid":"149435149","full_name":"XGHeaven/nos-node-sdk","owner":"XGHeaven","description":"A Modern Javascript SDK for NOS (163yun object storage)","archived":false,"fork":false,"pushed_at":"2022-02-12T08:00:33.000Z","size":1329,"stargazers_count":24,"open_issues_count":17,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-27T19:28:57.810Z","etag":null,"topics":["nos","nos-node-sdk"],"latest_commit_sha":null,"homepage":"http://nos-node-sdk.xgheaven.com","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/XGHeaven.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-19T10:43:02.000Z","updated_at":"2024-09-21T15:27:25.000Z","dependencies_parsed_at":"2022-08-07T20:01:11.946Z","dependency_job_id":null,"html_url":"https://github.com/XGHeaven/nos-node-sdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/XGHeaven/nos-node-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGHeaven%2Fnos-node-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGHeaven%2Fnos-node-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGHeaven%2Fnos-node-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGHeaven%2Fnos-node-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XGHeaven","download_url":"https://codeload.github.com/XGHeaven/nos-node-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGHeaven%2Fnos-node-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267945456,"owners_count":24170219,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["nos","nos-node-sdk"],"created_at":"2024-10-15T00:42:38.960Z","updated_at":"2025-07-30T21:37:36.483Z","avatar_url":"https://github.com/XGHeaven.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NOS Node.js SDK\n\n[![Coverage Status](https://coveralls.io/repos/github/XGHeaven/nos-node-sdk/badge.svg?branch=master)](https://coveralls.io/github/XGHeaven/nos-node-sdk?branch=master)\n[![Build Status](https://travis-ci.org/XGHeaven/nos-node-sdk.svg?branch=develop)](https://travis-ci.org/XGHeaven/nos-node-sdk)\n\nNOS Node.js SDK 实现了 NOS 对象操作接口，基于此 SDK 能方便快速地实现 JavaScript 应用程序来使用 NOS 的对象存储服务。\n\n\u003e NOS 是网易云推出的对象存储服务，稳定可靠\n\n## 为什么会有这个项目？\n\n主要原因是官方的 `nos-node-sdk` 有如下问题\n\n- 不符合 JavaScript 命名规范，不支持 Promise\n- 代码质量过差\n- 代码提示能力不足\n- 不支持 TypeScript\n- 年久失修\n\n## Feature\n\n- Full Typescript 支持，几乎不需要文档就可以上手\n- Support Async/Await or Callback\n- 操作简单专注，不会给你返回额外的信息\n- 丰富的测试用例\n- 支持创建直传 Token\n\n## 设计哲学\n\n在设计 API 的时候，遵循了一些设计原则。\n\n- **Keep it Simple** 一切都是那么直观，体现在接口上面就是见名明意。比如 getObject 就是获取对象内容，返回值便是 Buffer/string/Stream，而不是类似于 `{err: Error, data: xxx}` 的结构，你只是想得到内容体，为何要返回这么多数据。Believe me, It's a Trouble.\n- **Arguments Bus** 参数总线。将参数都整合在一个对象中传递给函数，而不是散落在函数的参数中。这样有力于在后面版本的迭代中，保证接口的兼容性。例如 `getObject({objectKey: 'key', bucket: 'bucket'})` 而不是 `getObject('key', 'bucket', options)`\n- **Throw as Possible** 如果有错误，能抛出就抛出，而不是内部消化，然后包装成返回参数。例如 `deleteObject(params).then(() =\u003e console.log('success')).catch(() =\u003e console.log('error'))` 而不是 `deleteObject(params).then(success =\u003e console.log(success))`\n\n## QuickStart\n\n```typescript\nimport { NosClient } from '@xgheaven/nos-node-sdk'\n\nconst client = new NosClient({\n  accessKey: 'your-access-key',\n  accessSecret: 'your-access-secret',\n  endpoint: 'http://nos-eastchina1.126.net', // endpoint，不同地域不同\n  defaultBucket: 'nos-test', // 默认的 Bucket，如果不设置，那么需要在单独的每次请求中进行设置\n})\n\nclient.putObject({\n  objectKey: 'test-file.txt',\n  body: Buffer.from('test'), // 支持 Buffer/Readable/string\n}).then(() =\u003e {\n  return client.getObject({\n    objectKey: 'test-file.txt',\n    encode: 'utf-8', // 支持 'buffer' | 编码 | 'stream'\n  })\n}).then(content =\u003e {\n  console.log(content)\n})\n\nclient.listObject({\n  limit: 10\n}).then(ret =\u003e {\n  console.log(ret)\n  // 所有的 List 操作接口返回的数据都是类似的，比如 listObject, listBucket, listParts, listMultipart\n  // ret 包括 items(元素)，limit(请求的数量)，nextMarker(下一个标记)\n  // 通过 limit 和 nextMarker 的配合，可以实现分页的效果\n})\n```\n\n更多信息，请查看 [API 文档](http://nos-node-sdk.xgheaven.com)(Typedoc generated).\n\n## TODO\n\n- [ ] HTTPS Endpoint 支持\n- [x] [文档支持](http://nos-node-sdk.xgheaven.com)\n- [ ] 增加测试用例\n- [x] ~~国际化翻译~~ 觉得也没歪果仁会用\n\n## Coverage\n\n```\n----------------------|----------|----------|----------|----------|-------------------|\nFile                  |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |\n----------------------|----------|----------|----------|----------|-------------------|\nAll files             |    94.68 |     83.7 |    93.02 |    95.78 |                   |\n src                  |       98 |    94.12 |      100 |       98 |                   |\n  client.ts           |       98 |    94.12 |      100 |       98 |               143 |\n src/exts             |    94.34 |    77.32 |    97.14 |     94.3 |                   |\n  auth.ts             |      100 |      100 |      100 |      100 |                   |\n  bucket.ts           |    96.23 |    85.71 |      100 |    96.15 |             62,85 |\n  multipart-upload.ts |    93.64 |    77.78 |    92.86 |    93.64 |... 74,276,277,278 |\n  object.ts           |    93.18 |       72 |      100 |     93.1 |... 82,233,234,236 |\n src/lib              |    94.01 |    87.76 |     88.1 |     97.4 |                   |\n  authorization.ts    |      100 |    83.33 |      100 |      100 |                29 |\n  constant.ts         |      100 |      100 |      100 |      100 |                   |\n  error.ts            |      100 |       80 |      100 |      100 |                 3 |\n  request.ts          |      100 |      100 |      100 |      100 |                   |\n  resource.ts         |    94.12 |    81.25 |      100 |      100 |          14,48,67 |\n  util.ts             |    91.67 |    95.45 |    83.33 |    95.29 |      36,37,38,130 |\n src/type             |      100 |      100 |      100 |      100 |                   |\n  bucket.ts           |      100 |      100 |      100 |      100 |                   |\n----------------------|----------|----------|----------|----------|-------------------|\n```\n\n## Thanks\n\n项目还比较年轻，如果有任何考虑不周的地方欢迎大家进行反馈，我也会积极处理。\n争取有一天能够替代原先的 SDK，减轻大家使用上的烦恼。\n\n[CHANGELOG](./CHANGELOG.md)\n\n\u003e 虽然不认为很多人都知道 NOS，哈哈哈\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgheaven%2Fnos-node-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxgheaven%2Fnos-node-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgheaven%2Fnos-node-sdk/lists"}