{"id":21812884,"url":"https://github.com/neverland/apify","last_synced_at":"2025-10-30T17:43:31.312Z","repository":{"id":56208600,"uuid":"102453264","full_name":"Neverland/apify","owner":"Neverland","description":"A api solution for browser based Fetch api!","archived":false,"fork":false,"pushed_at":"2021-04-13T12:09:30.000Z","size":285,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T01:34:32.070Z","etag":null,"topics":["apify-api","requset"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/i-apify","language":"JavaScript","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/Neverland.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}},"created_at":"2017-09-05T08:10:08.000Z","updated_at":"2021-04-13T12:06:25.000Z","dependencies_parsed_at":"2022-08-15T14:40:51.731Z","dependency_job_id":null,"html_url":"https://github.com/Neverland/apify","commit_stats":null,"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"purl":"pkg:github/Neverland/apify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neverland%2Fapify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neverland%2Fapify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neverland%2Fapify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neverland%2Fapify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neverland","download_url":"https://codeload.github.com/Neverland/apify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neverland%2Fapify/sbom","scorecard":{"id":100520,"data":{"date":"2025-08-11","repo":{"name":"github.com/Neverland/apify","commit":"9aee057210e0951556ac6c6d8c618bacc3d83a44"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"Code-Review","score":0,"reason":"Found 0/21 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":"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":"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":"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":"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":"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":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 14 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-15T10:02:52.762Z","repository_id":56208600,"created_at":"2025-08-15T10:02:52.762Z","updated_at":"2025-08-15T10:02:52.762Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279011856,"owners_count":26085005,"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-10-12T02:00:06.719Z","response_time":53,"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":["apify-api","requset"],"created_at":"2024-11-27T14:25:36.372Z","updated_at":"2025-10-12T15:39:19.322Z","avatar_url":"https://github.com/Neverland.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# apify\nA api solution for `web browser` based Fetch api!\n\n[![Build Status](https://www.travis-ci.org/Neverland/apify.svg)](https://www.travis-ci.org/Neverland/apify)\n[![npm](https://img.shields.io/npm/v/i-apify.svg)](https://www.npmjs.com/package/i-apify)\n[![Github All Releases](https://img.shields.io/npm/dm/i-apify.svg)](https://www.npmjs.com/package/i-apify)\n[![codecov](https://codecov.io/gh/Neverland/apify/branch/master/graph/badge.svg)](https://codecov.io/gh/Neverland/apify)\n\n```javascript\napi.method(payload, option);\n```\n## Description\n\u003e  基于fetch api的前端数据链路层封装，可以达到一次配置随意轻松使用！\n\napify 提供了以下功能\n   - requset用于发送请求支持`POST`，`GET` 请求, `PUT`，`DELETE`需要自己扩展\n   - apify 用于把配置处理为可以发送请求的函数化列表\n   - 可以使用apify处理过的简单发送请求方式，也可以直接用requset发送请求\n   - i-apify 使用了fetch Api的polyfill，可以直接使用 Headers 和 Response 类\n\n## Define\n\n```ecmascript 6\n\nimport {apify, request} from 'i-apify';\n\nlet list = {\n    getUser: '/api/v1/getUser',\n    getCity: '/api/method/getCity?type=normal'\n};\n\nexport default apify(request.post, list, \u003coption\u003e);\n\n```\n\n## Usage\n\n### request 对象\n\n\u003e request的post，get出了配合apify使用外均可以独立使用。\n\n```ecmascript 6\n\nimport {request} from 'i-apify';\n\nrequest.post('/api/v1/getUser', payload, \u003coption\u003e);\nrequest.get('/api/method/getCity?type=normal', payload, \u003coption\u003e);\n\n```\n\n### apify处理后的函数使用\n\n|参数|说明|default|\n|---|----|----|\n|payload| {Object string} | null |\n|option|{Object=}|{}|\n\n### 1. 直接使用\n```javascript\n\napi.getUser({\n    id: ${userId},\n    name: ${userName}\n})\n    .then(response =\u003e {\n        // do something\n    })\n    .catch();\n\n```\n\n### 2. 使用local option覆盖global option\n```javascript\napi.getCity(null, \u003coption\u003e)\n    .then()\n    .catch();\n```\n\n## Option\n\n### 默认option及初始值\n\n|参数|default|说明|Fetch API 参数|\n|---|----|----|----|\n|method|POST|请求方式|Y|\n|credentials|include|默认可以跨域请求|Y|\n|headers|'Accept': 'application/json' \u003cbr\u003e'Content-Type':'application/json'|数据类型JSON|Y|\n|dataType|json|收发数据类型json|N|\n|x-timeout|5000ms|超时时间|N|\n|x-silent|false|用于在hook或handler控制loading是否静默|N|\n|x-message|true|用于在hook或handler控制是否展示异常等逻辑，可以配合ui-dialog。|N|\n\n### 全局配置与局部配置\n \u003e可以使用apify的option来配置所有方法，\n \n```javascript\nlet option = {\n    'x-timeout': 1000 * 10\n};\n\napify(request.post, list, option);\n```\n\n\u003e发送请求时可以对当前方法进行最终配置\n\n```javascript\n\napi.getUser(null, {\n    timeout: 1000 * 6,\n    dataType: 'formData' // formdata需要在payload handler中支持\n})\n    .then()\n    .catch();\n\n```\n\n```javascript\nimport {apify, request} from 'i-apify';\n\nlet list = {\n    getUser: '/api/v1/getUser',\n};\n\nlet option = {\n    hook: {\n        beforeRequest({option}) {\n            if (!option['x-silent']) {\n                ui.loading.show();\n            }\n        },\n        requestSuccess(data) {\n            if (!option['x-silent']) {\n                ui.loading.hide();\n            }\n        }\n    },\n    handler: {\n        success(data, option) {\n\n        },\n        error(error, option) {\n            if (option['x-message']) {\n                ui.alert(error.message);\n            }\n        }\n    }\n};\n\nlet api = apify(request.post, list, option);\n\n// 请求时会有loading，错误会弹窗提示\napi.getUser(null)\n    .then()\n    .catch();\n\n// 局部配置会覆盖全局配置\n// 请求时不会有loading，错误不会弹窗提示\napi.getUser(null, {\n    'x-silent': true,\n    'x-message': false,\n})\n    .then()\n    .catch();\n\n```\n\n通过apify, 或者api.method的option参数可以使用所有fetch api的配置参数。\n\n### fetch option\n\n\u003e关于fetch api, 可以通过option直接支持fetch api的配置。\n[Fetch api](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)\n\n```javascript\n\nlet option = {\n    method: 'GET',\n    mode: 'cors',\n    cache: 'default' \n};\n\n// global\n\napify(request.post, list, option);\n\n// local\napi.getUser(payload, option);\n```\n\n## hook\n\n\u003e通过hook函数可以对请求流程进行精细控制\n\n### hook fetch进程钩子函数\n\n|函数名|调用阶段|\n|----|----|\n|beforeRequest(option)|发送请求前执行|\n|timeout(option)|超时时执行|\n|requestSuccess(option, response)|请求成功后执行|\n|afterParse(option, data)|解析fetch的response后执行|\n|requestFail(option, error)|请求失败后执行|\n\n## handler 请求后数据处理函数\n\n\u003e使用handler可以对请求成功或者失败后对所所获取的数据或逻辑进行最后处理\n\n|参数|说明|\n|----|----|\n|data|通过fetch api所获得的数据|\n|option|请求时使用的最终配置|\n\n### handler配置\n```javascript\n\nimport {apify, request} from 'i-apify';\n\nlet list = {\n    getUser: '/api/v1/getUser',\n};\n\nlet option = {\n    handler: {\n        success(result, option) {\n            // 可以在这里把数据处理成自己想要对格式\n        },\n        error(data, option) {\n            // 可以在这里把数据处理成自己想要对格式\n            return data;\n        },\n        payload(data, option) {\n            // 可以在这里对fetch的option 进行处理\n            /* global cleenDeep */\n\n            return cleenDeep(data);\n        }\n    }\n}\n\nexport default apify(request.post, list, option);\n\n```\n\n## 配合async awiat 使用\n\n```javascript\nlet option = {\n    handler: {\n        success(data, option) {\n            // 可以在这里对response在进行细分\n            if (data) {\n                return Promise.resolve(data);\n            }\n            \n            return Promise.reject([1, 2, 3]);\n        }\n    }\n}\n\nasync function () {\n    try {\n        await api.getUser();\n    }\n    catch({data}) {\n        console.log(data) // [1, 2, 3]\n    }\n}\n\n```\n## fetch 默认支持的参数\n```\n'method',        // GET/POST等\n'headers',       // 一个普通对象，或者一个 Headers 对象\n'body',          // 传递给服务器的数据，可以是字符串/Buffer/Blob/FormData，如果方法是 GET/HEAD，则不能有此参数\n'mode',          // cors / no-cors / same-origin， 是否跨域，默认是 no-cors\n'credentials',   // omit / same-origin / include\n'cache',         // default / no-store / reload / no-cache / force-cache / only-if-cached\n'redirect',      // follow / error / manual\n'referrer',      // no-referrer / client / 或者一个url\n'referrerPolicy',// no-referrer / no-referrer-when-downgrade / origin /  origin-when-cross-origin / unsafe-url\n'integrity'      // 资源完整性验证\n```\n\n## Building \u0026 Testing\n\n### Building\n```\n    npm run build\n```\n### testing\n```\n    npm run test\n```\n\n## License MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneverland%2Fapify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneverland%2Fapify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneverland%2Fapify/lists"}