{"id":23870348,"url":"https://github.com/node-ecosystem/vite-plugin-build-routes","last_synced_at":"2026-02-14T08:03:20.504Z","repository":{"id":269460834,"uuid":"907432798","full_name":"node-ecosystem/vite-plugin-build-routes","owner":"node-ecosystem","description":"Vite Plugin to build API routes","archived":false,"fork":false,"pushed_at":"2025-01-08T23:16:34.000Z","size":2062,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-27T12:09:21.536Z","etag":null,"topics":["api","api-rest","api-routes","build","plugin","routes","routing","vite"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-ecosystem.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":"2024-12-23T15:11:31.000Z","updated_at":"2025-01-08T23:16:00.000Z","dependencies_parsed_at":"2025-01-09T00:34:00.286Z","dependency_job_id":"b13933fa-7e0b-4a8e-b9e2-fae8c42cad63","html_url":"https://github.com/node-ecosystem/vite-plugin-build-routes","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"6ccf39530aeabe7a92d22c3ebc1ec247f7d5b773"},"previous_names":["node-ecosystem/vite-plugin-api-autorouter","node-ecosystem/vite-plugin-build-routes"],"tags_count":3,"template":false,"template_full_name":"templates-ecosystem/template-yarn-berry","purl":"pkg:github/node-ecosystem/vite-plugin-build-routes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-ecosystem%2Fvite-plugin-build-routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-ecosystem%2Fvite-plugin-build-routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-ecosystem%2Fvite-plugin-build-routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-ecosystem%2Fvite-plugin-build-routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-ecosystem","download_url":"https://codeload.github.com/node-ecosystem/vite-plugin-build-routes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-ecosystem%2Fvite-plugin-build-routes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29439821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T07:24:13.446Z","status":"ssl_error","status_checked_at":"2026-02-14T07:23:58.969Z","response_time":53,"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":["api","api-rest","api-routes","build","plugin","routes","routing","vite"],"created_at":"2025-01-03T13:53:58.986Z","updated_at":"2026-02-14T08:03:20.489Z","avatar_url":"https://github.com/node-ecosystem.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-build-routes\n\nA Vite plugin to simplify the build of API routes: copy all files from a _target_ directory to a _build_ output directory.\n\n## ⚙️ Install\n```sh\nyarn add -D vite-plugin-build-routes\n```\n\n## 📖 Usage\n\nExample:\n- `/server/api` as _target_ directory that contains `/server/api/user/index.ts` file\n- `/dist` as _build_ output directory\n- register `vite-plugin-build-routes` plugin and server plugin (see below)\n- build with Vite (e.g. `yarn vite build`)\n- the _result_ is `/dist/server/api/user/index.mjs`\n\n### Register the Vite Plugin (example with [Vike](https://vike.dev))\n```ts\n// vite.config.ts\nimport vike from 'vike/plugin'\nimport { vikeNode } from 'vike-node/plugin'\nimport type { UserConfig } from 'vite'\nimport viteBuildRoutes from 'vite-plugin-build-routes'\n\nexport default {\n  plugins: [\n    vike(),\n    vikeNode('server/index.ts'),\n    viteBuildRoutes('server/api')\n    // OR use a pattern instead of default '**/*.ts'\n    // viteBuildRoutes({\n    //   entry: 'server/api',\n    //   pattern: '**/*.js'\n    // })\n  ]\n} satisfies UserConfig\n```\n\n### Use the Server Plugin (example with [Hono](https://hono.dev))\n\nUse the [universal-autorouter](https://github.com/node-ecosystem/universal-autorouter) package to automatically scan and load all routes to the server.\n\n```ts\n// /server/index.ts\nimport path from 'node:path'\nimport { serve } from '@hono/node-server'\nimport { Hono } from 'hono'\nimport vike from 'vike-node/hono'\nimport autoloadRoutes from 'universal-autorouter'\n\nconst app = new Hono()\n\nawait autoloadRoutes(app, {\n  pattern: process.env.NODE_ENV === 'production' ? '**/*.mjs' : '**/*.ts',\n  prefix: '/api',\n  routesDir: path.resolve(import.meta.dirname, 'api'),\n  viteDevServer: globalThis.__vikeNode?.viteDevServer  // needed for Vite's HMR\n})\n\napp.use(vike())\n\nconst port = +(process.env.PORT || 3000)\n\nserve({\n  fetch: app.fetch,\n  port\n}, () =\u003e console.log(`Server running at http://localhost:${port}`))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-ecosystem%2Fvite-plugin-build-routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-ecosystem%2Fvite-plugin-build-routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-ecosystem%2Fvite-plugin-build-routes/lists"}