{"id":16489097,"url":"https://github.com/thundernet8/vite-plugin-api-mocker","last_synced_at":"2025-03-01T04:22:31.339Z","repository":{"id":57393070,"uuid":"343320784","full_name":"thundernet8/vite-plugin-api-mocker","owner":"thundernet8","description":"A local api mocker plugin for vite","archived":false,"fork":false,"pushed_at":"2021-03-01T07:26:02.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-29T15:22:46.499Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/thundernet8.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":"2021-03-01T07:02:23.000Z","updated_at":"2022-07-22T10:58:21.000Z","dependencies_parsed_at":"2022-09-15T02:21:46.669Z","dependency_job_id":null,"html_url":"https://github.com/thundernet8/vite-plugin-api-mocker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundernet8%2Fvite-plugin-api-mocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundernet8%2Fvite-plugin-api-mocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundernet8%2Fvite-plugin-api-mocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundernet8%2Fvite-plugin-api-mocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thundernet8","download_url":"https://codeload.github.com/thundernet8/vite-plugin-api-mocker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241314989,"owners_count":19942761,"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","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":"2024-10-11T13:43:03.170Z","updated_at":"2025-03-01T04:22:31.320Z","avatar_url":"https://github.com/thundernet8.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-api-mocker\n\nA local api mocker plugin for vite，with delay response and auto-added api path prefix following file system supports\n\n## install\n\n```bash\nyarn add vite-plugin-api-mocker -D\n```\n\n## usage\n\n```ts\n// vite.config.ts\nimport { defineConfig } from 'vite';\nimport mockerPlugin from 'vite-plugin-api-mocker';\n\nexport default defineConfig({\n  // ... other config\n  plugins: [\n    mockerPlugin({\n      dir: Path.join(process.cwd(), 'mock'), // mock files root folder\n      delay: 1000, // delay 1000ms before response\n    }),\n  ],\n});\n```\n\n## mock file\n\n```js\n// /mockroot/index.js -\u003e GET /hello\nexports['GET /hello'] = {\n  msg: 'hello world',\n};\n\n// /mockroot/api/example.js -\u003e GET /api/example/:id\nexports['GET /:id(\\\\d+)'] = {\n  foo: 'bar',\n};\n\n// /mockroot/api/example.js -\u003e POST /api/example/users\nexports['POST /users'] = (req, res) =\u003e {\n    res.writeHead(200, {\n        'content-type': 'application/json'\n    });\n    res.end({\n        code: 0,\n        msg: '',\n        data: [{\n            // ...\n        }]\n    })\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthundernet8%2Fvite-plugin-api-mocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthundernet8%2Fvite-plugin-api-mocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthundernet8%2Fvite-plugin-api-mocker/lists"}