{"id":20699709,"url":"https://github.com/aspida/aspida-mock","last_synced_at":"2025-09-12T10:43:10.324Z","repository":{"id":39281873,"uuid":"291165842","full_name":"aspida/aspida-mock","owner":"aspida","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-05T22:47:39.000Z","size":384,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-03T08:58:49.406Z","etag":null,"topics":["mock","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/aspida.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-28T23:34:36.000Z","updated_at":"2025-03-14T01:26:12.000Z","dependencies_parsed_at":"2024-06-19T11:20:24.598Z","dependency_job_id":"a0b773bf-3526-428f-b94f-236617eabe9d","html_url":"https://github.com/aspida/aspida-mock","commit_stats":{"total_commits":34,"total_committers":2,"mean_commits":17.0,"dds":0.02941176470588236,"last_synced_commit":"94d8f4cb2e7aee7c12812ad15c6347c1e3ff765c"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/aspida/aspida-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspida%2Faspida-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspida%2Faspida-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspida%2Faspida-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspida%2Faspida-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aspida","download_url":"https://codeload.github.com/aspida/aspida-mock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspida%2Faspida-mock/sbom","scorecard":{"id":212842,"data":{"date":"2025-08-11","repo":{"name":"github.com/aspida/aspida-mock","commit":"94d8f4cb2e7aee7c12812ad15c6347c1e3ff765c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.1,"checks":[{"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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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/14 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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1","Warn: no topLevel permission defined: .github/workflows/release-drafter.yml:1","Info: no jobLevel write permissions found"],"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/aspida/aspida-mock/nodejs.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/aspida/aspida-mock/nodejs.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/aspida/aspida-mock/nodejs.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/aspida/aspida-mock/nodejs.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/aspida/aspida-mock/nodejs.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/aspida/aspida-mock/nodejs.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release-drafter.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/aspida/aspida-mock/release-drafter.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:28","Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:52","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   2 npmCommand dependencies pinned"],"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":"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":"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":"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":"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":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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 21 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"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T01:04:24.796Z","repository_id":39281873,"created_at":"2025-08-17T01:04:24.797Z","updated_at":"2025-08-17T01:04:24.797Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274800068,"owners_count":25352173,"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-09-12T02:00:09.324Z","response_time":60,"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":["mock","typescript"],"created_at":"2024-11-17T00:31:34.508Z","updated_at":"2025-09-12T10:43:10.261Z","avatar_url":"https://github.com/aspida.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aspida-mock\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\u003cbr /\u003e\n\u003cbr /\u003e\n\u003cimg src=\"https://aspida.github.io/aspida/logos/svg/black.svg\" alt=\"aspida\" title=\"aspida\" width=\"1000\" height=\"120\" /\u003e\n\u003cbr /\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/aspida-mock\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/aspida-mock\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/aspida-mock\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/aspida-mock\" alt=\"npm download\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003eTypeScript friendly RESTful API mock for aspida.\u003c/p\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/aspida/aspida-mock#readme\"\u003e🇺🇸English\u003c/a\u003e |\n  \u003ca href=\"https://github.com/aspida/aspida-mock/tree/master/docs/ja#readme\"\u003e🇯🇵日本語\u003c/a\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n## Features\n\n- API mock dedicated to TypeScript using the type definition of [aspida](https://github.com/aspida/aspida).\n- Supports all HTTP methods such as `GET`/`POST`/`PUT`/`DELETE` in a few lines.\n- No server required, works only with browser.\n\n## Usage\n\n### Installation\n\n- Using [npm](https://www.npmjs.com/):\n\n  ```sh\n  $ npm install aspida-mock @aspida/axios axios\n  # $ npm install aspida-mock @aspida/fetch\n  # $ npm install aspida-mock @aspida/node-fetch node-fetch\n  # $ npm install aspida-mock @aspida/ky ky\n  ```\n\n- Using [Yarn](https://yarnpkg.com/):\n\n  ```sh\n  $ yarn add aspida-mock @aspida/axios axios\n  # $ yarn add aspida-mock @aspida/fetch\n  # $ yarn add aspida-mock @aspida/node-fetch node-fetch\n  # $ yarn add aspida-mock @aspida/ky ky\n  ```\n\n### Creating API endpoints\n\nExport mockMethods in aspida type definition file.\n\n`api/users/index.ts`\n\n```ts\nimport { mockMethods } from \"aspida-mock\";\n\nexport type Methods = {\n  post: {\n    query: { id: number };\n    reqHeaders: { val: string };\n    reqBody: { name: string };\n    resHeaders: { token: string };\n    resBody: {\n      id: number;\n      name: string;\n    };\n  };\n};\n\nexport default mockMethods\u003cMethods\u003e({\n  post: ({ query, reqHeaders, reqBody }) =\u003e ({\n    status: 200,\n    resHeaders: { token: reqHeaders.val },\n    resBody: {\n      id: query.id,\n      name: reqBody.name,\n    },\n  }),\n});\n```\n\n`package.json`\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"aspida \u0026\u0026 aspida-mock\"\n  }\n}\n```\n\n`tarminal`\n\n```sh\n$ npm run build\n```\n\n`index.ts`\n\n```ts\nimport aspidaClient from \"@aspida/axios\"; // \"@aspida/fetch\", \"@aspida/node-fetch\", \"@aspida/ky\"\nimport api from \"./api/$api\";\nimport mock from \"./api/$mock\";\n\nconst client = process.env.NODE_ENV === \"development\" ? mock(aspidaClient()) : api(aspidaClient());\n\n(async () =\u003e {\n  const res = await client.users.post({\n    query: { id: 0 },\n    headers: { val: \"hoge\" },\n    data: { name: \"fuga\" },\n  });\n\n  console.log(res);\n  /*\n  {\n    status: 200,\n    headers: { token: \"hoge\" },\n    data: { id: 0, name: \"fuga\" }\n  }\n  */\n})();\n```\n\n### Middleware\n\nFor every request, you can insert processing before reaching mockMethods.\n\n`api/@middleware.ts`\n\n```ts\nimport { mockMiddleware } from \"aspida-mock\";\n\nexport default mockMiddleware([\n  (req, _res, next) =\u003e {\n    next({ ...req, query: { hoge: req.query.hoge + 1 } });\n  },\n  (req, res) =\u003e {\n    res({ status: 200, resBody: { fuga: req.query.hoge + 2 } });\n  },\n]);\n```\n\n`api/users/index.ts`\n\n```ts\nimport { mockMethods } from \"aspida-mock\";\n\nexport type Methods = {\n  get: {\n    query: { hoge: number };\n    resBody: {\n      fuga: number;\n    };\n  };\n};\n\nexport default mockMethods\u003cMethods\u003e({\n  get: ({ query }) =\u003e ({\n    status: 200,\n    resBody: { fuga: query.hoge + 4 },\n  }),\n});\n```\n\n`index.ts`\n\n```ts\nimport aspidaClient from \"@aspida/axios\"; // \"@aspida/fetch\", \"@aspida/node-fetch\", \"@aspida/ky\"\nimport mock from \"./api/$mock\";\n\nconst client = mock(aspidaClient());\n\n(async () =\u003e {\n  const res = await client.users.get({\n    query: { hoge: 0 },\n  });\n\n  console.log(res);\n  /*\n  {\n    status: 200,\n    data: { fuga: 3 }\n  }\n  */\n})();\n```\n\n### Options\n\naspida-mock has several options available.\n\n#### `delayMSec: number`\n\nSimulate response delay.\n\n```ts\nimport aspidaClient from \"@aspida/axios\"; // \"@aspida/fetch\", \"@aspida/node-fetch\", \"@aspida/ky\"\nimport mock from \"./api/$mock\";\n\nconst client = mock(aspidaClient(), { delayMSec: 500 });\n\n(async () =\u003e {\n  console.time();\n  await client.users.$get();\n  console.timeEnd(); // default: 506.590ms\n})();\n```\n\n#### `log: boolean`\n\nSwitch request log output.\n\n```ts\nimport aspidaClient from \"@aspida/axios\"; // \"@aspida/fetch\", \"@aspida/node-fetch\", \"@aspida/ky\"\nimport mock from \"./api/$mock\";\n\nconst client = mock(aspidaClient(), { log: true });\n\n(async () =\u003e {\n  await client.users.$get({ query: { bar: \"baz\" } });\n  // [mock] get: /users?bar=baz =\u003e 200\n})();\n```\n\n### Cautions\n\n#### `.gitignore`\n\nExclude `$mock.ts` generated by aspida-mock in the build from [Git](https://git-scm.com/) monitoring.\n\n```sh\n$ echo \"\\$mock.ts\" \u003e\u003e .gitignore\n\n# If Windows (Command Prompt)\n\u003e echo $mock.ts \u003e\u003e .gitignore\n```\n\n## Command Line Interface Options\n\nThe following options can be specified in the Command Line Interface.\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eOption\u003c/th\u003e\n      \u003cth\u003eType\u003c/th\u003e\n      \u003cth\u003eDefault\u003c/th\u003e\n      \u003cth width=\"100%\"\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd nowrap\u003e\u003ccode\u003e--config\u003c/code\u003e\u003cbr /\u003e\u003ccode\u003e-c\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e\"aspida.config.js\"\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eSpecify the path to the configuration file.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd nowrap\u003e\u003ccode\u003e--watch\u003c/code\u003e\u003cbr /\u003e\u003ccode\u003e-w\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        Enable watch mode.\u003cbr /\u003e\n        Regenerate \u003ccode\u003e$mock.ts\u003c/code\u003e according to\n        the increase / decrease of the API endpoint file.\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd nowrap\u003e\u003ccode\u003e--version\u003c/code\u003e\u003cbr /\u003e\u003ccode\u003e-v\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003ePrint aspida-mock version.\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n## Configuration\n\naspida-mock refers to only \"input\" among the items of the aspida configuration file `aspida.config.js`.  \nThis allows you to always generate a mock from the same directory as aspida.  \n[Options of aspida.config.js](https://github.com/aspida/aspida#options-of-aspidaconfigjs)\n\n## License\n\naspida-mock is licensed under a [MIT License](https://github.com/aspida/aspida-mock/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspida%2Faspida-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faspida%2Faspida-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspida%2Faspida-mock/lists"}