{"id":45019741,"url":"https://github.com/ddvjs/ddv-restful-api","last_synced_at":"2026-02-19T02:04:18.667Z","repository":{"id":95752884,"uuid":"78345381","full_name":"ddvjs/ddv-restful-api","owner":"ddvjs","description":"ddv-restful-api","archived":false,"fork":false,"pushed_at":"2019-12-19T08:01:18.000Z","size":607,"stargazers_count":3,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-18T12:32:30.081Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/ddvjs.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-01-08T13:46:05.000Z","updated_at":"2019-12-19T08:01:20.000Z","dependencies_parsed_at":"2023-05-25T00:45:46.464Z","dependency_job_id":null,"html_url":"https://github.com/ddvjs/ddv-restful-api","commit_stats":{"total_commits":207,"total_committers":6,"mean_commits":34.5,"dds":0.5169082125603865,"last_synced_commit":"1d7d0a0e2295bd1c55c50716768181d5858c7a6e"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/ddvjs/ddv-restful-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddvjs%2Fddv-restful-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddvjs%2Fddv-restful-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddvjs%2Fddv-restful-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddvjs%2Fddv-restful-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddvjs","download_url":"https://codeload.github.com/ddvjs/ddv-restful-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddvjs%2Fddv-restful-api/sbom","scorecard":{"id":330471,"data":{"date":"2025-08-11","repo":{"name":"github.com/ddvjs/ddv-restful-api","commit":"1d7d0a0e2295bd1c55c50716768181d5858c7a6e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T03:27:18.077Z","repository_id":95752884,"created_at":"2025-08-18T03:27:18.077Z","updated_at":"2025-08-18T03:27:18.077Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29600852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T00:59:38.239Z","status":"online","status_checked_at":"2026-02-19T02:00:07.702Z","response_time":117,"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":[],"created_at":"2026-02-19T02:04:16.124Z","updated_at":"2026-02-19T02:04:18.655Z","avatar_url":"https://github.com/ddvjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ddv-restful-api\n\u003e这是一个基于[Promise](https://www.promisejs.org/)封装的请求模块\n\n## 安装\n\n**npm:**\n\n```shell\n$ npm install ddv-restful-api\n```\n\n**引入:**\n\n```javascript\nimport * as api from 'ddv-restful-api';\n```\n\n\n**独立版本:**\n\n你可以直接使用`\u003cscript\u003e`标签直接引入， `ddvRestFulApi` 会被注册为一个全局变量。\n\n```html\n\u003cscript src=\"https://unpkg.com/ddv-restful-api/dist/api.js\"\u003e\u003c/script\u003e\n```\n\n需要注意的是，为了兼容IE9以下版本浏览器需要预先加载[es5-shim](https://github.com/es-shims/es5-shim)。\n\n```html\n\u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/es5-shim/3.4.0/es5-shim.min.js\"\u003e\u003c/script\u003e\n```\n\n**引入:**\n\n```javascript\nvar api = ddvRestFulApi;\n```\n\n## 配置\n\n```javascript\n//设置默认请求域名\napi.setBaseUrl('http://api.testabc.com');\n//自定义头前缀\napi.setHeadersPrefix('x-hz-');\n//是否长期会话\napi.setLongStorage(false);\n//设置会话初始化最大自动尝试次数，默认3次\napi.setSessionInitTrySum(3);\n//设置初始化session的path，默认/session/init\napi.setSessionInitPath('/session/init');\n\n```\n\n## 使用\n\n\u003e* `restful-api` 支持 `GET`、`POST`、`PUT`、`DELETE`四种请求方式，以及拥有 `get`、`post`、`put`、 `del`（或 `delete`）、`api`五个方法。\n\u003e* 分别使用方法 `get`、`post`、`put`、 `del`（或 `delete`）执行对应的请求。\n\u003e* `api`方法支持模拟`GET`、`POST`、`PUT`、`DELETE` 以及更多请求方式。\n\n\n### 例子：\n##### 1、GET请求\n\n\u003e* `send` 发送的数据会自动转换为 `query` 服务器GET参数\n\u003e* `headers()` ：改变请求头：`api.get('/path').headers({})`。\n\u003e* `path()`：可以改变请求的path：`api.get('/path').path('/path2')`。\n\u003e* `query()` ：发送地址栏 `？` 后面的参数\n\u003e* `sendData()` ：`send`方法是 `sendData`一个别名\n\u003e* `req()`、`res()`： 如果在`node`服务器建立`http`服务，需要设置`req`和`res`来确定会话\n\u003e* `context()`： 这个是res和req的集合context({'req','res'})\n\n```javascript\nimport api from 'ddv-restful-api';\n\n//支持多维数组\napi.get('/v1_0/pc/raiders/news/type').send({\n    'array':[\n        '1',\n        '2',\n        '3',\n        {\n            'test':'ddv',\n            'ddvjs':['a','b','c']\n        }\n    ]\n}).then(function(res){\n    console.log('结果:',res);\n}).catch(function(e){\n    console.log('e',e.statusCode);\n    console.log('e',e.message);\n});\n```\n\u003e* 小提示如果您仅仅是使用get请求你可以选择\n\n```javascript\nimport {get as getApi} from 'ddv-restful-api';\n\n//支持多维数组\ngetApi('/v1_0/pc/raiders/news/type').send({\n    'array':[\n        '1',\n        '2',\n        '3',\n        {\n            'test':'ddv',\n            'ddvjs':['a','b','c']\n        }\n    ]\n}).then(function(res){\n    console.log('结果:',res);\n}).catch(function(e){\n    console.log('e',e.statusCode);\n    console.log('e',e.message);\n});\n\n```\n\u003e* 温馨提示:getApi是别名\n\n##### 2、POST请求\n\n\u003e* 类似GET，但是 `POST`、`PUT`、`DELETE` 支持 query() 和 send()\n\u003e* query 是服务器GET参数\n\u003e* send 是服务器POST参数，也就是请求体\n\n```javascript\nimport {post as postApi} from 'ddv-restful-api';\n\n//支持多维数组\npostApi('/v1_0/pc/raiders/news/type').send({\n    'array':[\n        '1',\n        '2',\n        '3',\n        {\n            'test':'ddv',\n            'ddvjs':['a','b','c']\n        }\n    ]\n}).then(function(res){\n    console.log('结果:',res);\n}).catch(function(e){\n    console.log('e',e.statusCode);\n    console.log('e',e.message);\n});\n```\n\n##### 3、使用api方法请求\n\n\u003e* 与上述例子类似\n\u003e* 可使用 `method()` 方法更改请示方式，默认是 `GET`。\n\n```javascript\nimport api from 'ddv-restful-api';\n\n//支持多维数组\napi('/v1_0/pc/raiders/news/type').method('PUT').send({\n    'array':[\n        '1',\n        '2',\n        '3',\n        {\n            'test':'ddv',\n            'ddvjs':['a','b','c']\n        }\n    ]\n}).then(function(res){\n    console.log('结果:',res);\n}).catch(function(e){\n    console.log('e',e.statusCode);\n    console.log('e',e.message);\n});\n```\n\n\n```javascript\nimport api from 'ddv-restful-api';\n\n//支持多维数组\napi.get('/v1_0/pc/raiders/news/type').send({\n    'array':[\n        '1',\n        '2',\n        '3',\n        {\n            'test':'ddv',\n            'ddvjs':['a','b','c']\n        }\n    ]\n}).then(function(res){\n    console.log('结果:',res);\n}).catch(function(e){\n    console.log('e',e.statusCode);\n    console.log('e',e.message);\n});\n```\n\u003e* 小提示如果您仅仅是使用get请求你可以选择\n\n```javascript\nimport {get as getApi} from 'ddv-restful-api';\n\n//支持多维数组\ngetApi('/v1_0/pc/raiders/news/type').send({\n    'array':[\n        '1',\n        '2',\n        '3',\n        {\n            'test':'ddv',\n            'ddvjs':['a','b','c']\n        }\n    ]\n}).then(function(res){\n    console.log('结果:',res);\n}).catch(function(e){\n    console.log('e',e.statusCode);\n    console.log('e',e.message);\n});\n\n```\n\u003e* 温馨提示:getApi是别名\n\n##### 2、POST请求\n\n\u003e* 类似GET，但是 `POST`、`PUT`、`DELETE` 支持 query() 和 send()\n\u003e* query 是服务器GET参数\n\u003e* send 是服务器POST参数，也就是请求体\n\n```javascript\nimport {post as postApi} from 'ddv-restful-api';\n\n//支持多维数组\npostApi('/v1_0/pc/raiders/news/type').send({\n    'array':[\n        '1',\n        '2',\n        '3',\n        {\n            'test':'ddv',\n            'ddvjs':['a','b','c']\n        }\n    ]\n}).then(function(res){\n    console.log('结果:',res);\n}).catch(function(e){\n    console.log('e',e.statusCode);\n    console.log('e',e.message);\n});\n```\n\n##### 3、使用api方法请求\n\n\u003e* 与上述例子类似\n\u003e* 可使用 `method()` 方法更改请示方式，默认是 `GET`。\n\n```javascript\nimport api from 'ddv-restful-api';\n\n//支持多维数组\napi('/v1_0/pc/raiders/news/type').method('PUT').send({\n    'array':[\n        '1',\n        '2',\n        '3',\n        {\n            'test':'ddv',\n            'ddvjs':['a','b','c']\n        }\n    ]\n}).then(function(res){\n    console.log('结果:',res);\n}).catch(function(e){\n    console.log('e',e.statusCode);\n    console.log('e',e.message);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddvjs%2Fddv-restful-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddvjs%2Fddv-restful-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddvjs%2Fddv-restful-api/lists"}