{"id":19848154,"url":"https://github.com/mys1024/vite-plugin-koa-mock","last_synced_at":"2026-01-25T15:01:37.669Z","repository":{"id":113522407,"uuid":"599171385","full_name":"mys1024/vite-plugin-koa-mock","owner":"mys1024","description":"Serve mock API with Koa.js in Vite projects.","archived":false,"fork":false,"pushed_at":"2024-10-18T07:09:03.000Z","size":375,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T03:37:06.490Z","etag":null,"topics":[],"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/mys1024.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":"2023-02-08T15:47:16.000Z","updated_at":"2024-10-18T07:09:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"384c7f4c-ccc6-4e1c-ada7-7dfa5e694729","html_url":"https://github.com/mys1024/vite-plugin-koa-mock","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":"mys1024/starter-node","purl":"pkg:github/mys1024/vite-plugin-koa-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mys1024%2Fvite-plugin-koa-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mys1024%2Fvite-plugin-koa-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mys1024%2Fvite-plugin-koa-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mys1024%2Fvite-plugin-koa-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mys1024","download_url":"https://codeload.github.com/mys1024/vite-plugin-koa-mock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mys1024%2Fvite-plugin-koa-mock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28754807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T13:59:49.818Z","status":"ssl_error","status_checked_at":"2026-01-25T13:59:33.728Z","response_time":113,"last_error":"SSL_read: 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":[],"created_at":"2024-11-12T13:16:24.051Z","updated_at":"2026-01-25T15:01:37.642Z","avatar_url":"https://github.com/mys1024.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-koa-mock\n\n[![npm-version](https://img.shields.io/npm/v/vite-plugin-koa-mock?style=flat-square\u0026color=%23cb3837)](https://www.npmjs.com/package/vite-plugin-koa-mock)\n[![license](https://img.shields.io/github/license/mys1024/vite-plugin-koa-mock?\u0026style=flat-square)](./LICENSE)\n\nEnglish | [中文](./README_zh.md)\n\nServe mock API with **Koa.js** in **Vite** projects.\n\n![logger](https://raw.githubusercontent.com/mys1024/vite-plugin-koa-mock/main/images/cover.png)\n\n## Install\n\n```shell\nnpm install -D vite-plugin-koa-mock\n```\n\n## Usage\n\nConfig `vite.config.js`:\n\n```javascript\nimport { defineConfig } from 'vite'\nimport KoaMock from 'vite-plugin-koa-mock'\n\nexport default defineConfig({\n  plugins: [\n    KoaMock({\n      mockDir: './mock',\n      proxyKeys: ['/api'],\n    }),\n  ],\n})\n```\n\nCreate `mock/index.js` or `mock/index.ts` with your mock APIs:\n\n```javascript\nimport { Router } from 'vite-plugin-koa-mock'\n\nexport const router = new Router()\n\nrouter.get('/api/foo', (ctx) =\u003e {\n  ctx.body = 'bar'\n})\n\nrouter.get('/api/bar', (ctx) =\u003e {\n  ctx.body = 'foo'\n})\n```\n\n## Options\n\n```typescript\nimport type { Options as CorsOptions } from '@koa/cors'\n\nexport interface KoaMockOptions {\n  /**\n   * The dir for mock APIs.\n   * @default './mock'\n   */\n  mockDir?: string\n\n  /**\n   * The port for mock server.\n   * @default 9719\n   */\n  port?: number\n\n  /**\n   * Keys for Vite's configuration `server.proxy`.\n   * @see https://vitejs.dev/config/server-options.html#server-proxy\n   * @default ['/api']\n   */\n  proxyKeys?: string[]\n\n  /**\n   * Whether to enable builtin logger middleware.\n   * @default true\n   */\n  logger?: boolean\n\n  /**\n   * Whether to enable builtin CORS middleware.\n   * You can configure the CORS middleware by setting an options object.\n   * @see https://github.com/koajs/cors#corsoptions\n   * @default true\n   */\n  cors?: boolean | CorsOptions\n\n  /**\n   * Whether to enable builtin body parser middleware.\n   * @see https://github.com/koajs/bodyparser\n   * @default true\n   */\n  bodyParser?: boolean\n}\n```\n\n## License\n\n[MIT](./LICENSE) License \u0026copy; 2024-PRESENT\n[mys1024](https://github.com/mys1024)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmys1024%2Fvite-plugin-koa-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmys1024%2Fvite-plugin-koa-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmys1024%2Fvite-plugin-koa-mock/lists"}