{"id":25613473,"url":"https://github.com/kszitt/next-initial-request","last_synced_at":"2026-05-16T11:33:34.977Z","repository":{"id":100400665,"uuid":"198937068","full_name":"kszitt/next-initial-request","owner":"kszitt","description":"next.js框架服务端数据请求、客户端获取数据插件","archived":false,"fork":false,"pushed_at":"2019-10-11T03:26:28.000Z","size":3,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-21T17:00:03.697Z","etag":null,"topics":["client","initial","next","nextjs","request","server"],"latest_commit_sha":null,"homepage":"","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/kszitt.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,"zenodo":null}},"created_at":"2019-07-26T03:07:26.000Z","updated_at":"2019-10-11T03:26:29.000Z","dependencies_parsed_at":"2023-05-14T10:15:45.429Z","dependency_job_id":null,"html_url":"https://github.com/kszitt/next-initial-request","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kszitt/next-initial-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kszitt%2Fnext-initial-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kszitt%2Fnext-initial-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kszitt%2Fnext-initial-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kszitt%2Fnext-initial-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kszitt","download_url":"https://codeload.github.com/kszitt/next-initial-request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kszitt%2Fnext-initial-request/sbom","scorecard":{"id":571808,"data":{"date":"2025-08-11","repo":{"name":"github.com/kszitt/next-initial-request","commit":"a14beb637974c09868f0c37f413623d3e0538751"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"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":"Code-Review","score":0,"reason":"Found 0/2 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":"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":"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":"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":"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":"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-20T16:32:44.809Z","repository_id":100400665,"created_at":"2025-08-20T16:32:44.810Z","updated_at":"2025-08-20T16:32:44.810Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33100873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["client","initial","next","nextjs","request","server"],"created_at":"2025-02-22T01:31:30.402Z","updated_at":"2026-05-16T11:33:34.972Z","avatar_url":"https://github.com/kszitt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### 语言\n[English](https://github.com/kszitt/next-initial-request/blob/master/README_EN.md)\n\n### 描述\nnext.js框架数据请求、获取插件。  \n\n### 安装\n``` javascript\nnpm install next-initial-request --save-dev\n```\n\n### 创建http请求（举例）  \n``` javascript\nasync function GetActivityById(id){\n  let response = await axios.get(`/api/v1/activity/info/${id}`);\n\n  return response.data;\n}\nasync function getActivity(params){\n  let response = await axios.get(`/api/v1/activity/all`, {params});\n\n  return response.data;\n}\n```\n### 引入\n``` javascript\nimport NextHttp from \"next-initial-request\"\n// or\nconst NextHttp = require(\"next-initial-request\");\n```\n### 服务端请求数据\n``` javascript\nstatic async getInitialProps ({req, pathname, query}) {\n  let props = {};\n\n  if(req){\n    // 并发\n    let results = await Promise.all([\n      getActivityById(query.id),\n      getActivity(),\n    ]);\n    /* // 同步请求（根据接口的数据请求接口时，可以用这种方式）\n    let results = [];\n    results[0] = await getActivityById(query.id);\n    results[2] = await getActivity(); */\n\n    props.initProps = NextHttp.initProps(results, [\"activity\", \"activityAll\"]);\n  }\n\n  return props;\n}\n```\n### 客户端获取数据\n``` javascript\nasync getActivity(){\n    let params = {\n        page: 1,\n        perpage: 5\n      },\n      // NextHttp.getProps()只会在服务端渲染一次，客户端直接请求\n      data = NextHttp.getProps(this, \"activityAll\") || await getActivity(params),\n      activityAll = [];\n\n    if(data.code === 200){\n      activityAll = data.items;\n    }\n\n    this.setState({\n      activityAll\n    })\n  }\n```\n### .initProps(results, keys)  \n服务端请求数据保存到`props`中  \n- results{ array|object } 要保存的数据，必须\n- keys{ string:array | string } 数据绑定的key值，必须\n### .getProps(this, key)  \n从`props`中获取数据（只会在服务端请求一次）\n- this{ object } 传入当前组件的`this`，必须\n- key{ string:array | string } 从`props`中根据`key`提取数据，必须\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkszitt%2Fnext-initial-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkszitt%2Fnext-initial-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkszitt%2Fnext-initial-request/lists"}