{"id":15730009,"url":"https://github.com/koistya/cloud-functions-routing","last_synced_at":"2026-04-20T10:03:27.945Z","repository":{"id":199144826,"uuid":"702225124","full_name":"koistya/cloud-functions-routing","owner":"koistya","description":"Google Cloud Functions example using Node.js, TypeScript, folder-based routing, hot module replacement (HMR), and unit tests.","archived":false,"fork":false,"pushed_at":"2023-10-09T16:53:59.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T02:41:37.109Z","etag":null,"topics":["cloud-functions","express","expressjs","gcp","google-cloud","next","nextjs","router","routing","typescript","unit-testing","vite","vitest"],"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/koistya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"koistya"}},"created_at":"2023-10-08T21:13:39.000Z","updated_at":"2024-08-10T16:44:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae7f8f77-b8c8-459f-b59b-5a9074a3df8d","html_url":"https://github.com/koistya/cloud-functions-routing","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"61326f77af24f334ea0e337bfae84c9a41ef9f19"},"previous_names":["koistya/cloud-functions-routing"],"tags_count":0,"template":false,"template_full_name":"kriasoft/graphql-starter-kit","purl":"pkg:github/koistya/cloud-functions-routing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koistya%2Fcloud-functions-routing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koistya%2Fcloud-functions-routing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koistya%2Fcloud-functions-routing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koistya%2Fcloud-functions-routing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koistya","download_url":"https://codeload.github.com/koistya/cloud-functions-routing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koistya%2Fcloud-functions-routing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32042294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"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":["cloud-functions","express","expressjs","gcp","google-cloud","next","nextjs","router","routing","typescript","unit-testing","vite","vitest"],"created_at":"2024-10-03T23:41:37.786Z","updated_at":"2026-04-20T10:03:27.928Z","avatar_url":"https://github.com/koistya.png","language":"TypeScript","funding_links":["https://github.com/sponsors/koistya"],"categories":[],"sub_categories":[],"readme":"# Google Cloud Functions Routing\n\nThis example demonstrates how to implement a simple folder-based routing for Google Cloud Functions including:\n\n- [x] Development server with live-reload (HMR)\n- [x] Code bundling with Vite\n- [x] Unit testing with Vitest\n\n## Tech Stack\n\nNode.js v18 or newer, TypeScript, Vite, Vitest, `path-to-regexp`.\n\n## Getting Started\n\n```bash\n$ git clone https://github.com/koistya/cloud-functions-routing\n$ cd ./cloud-functions-routing\n$ corepack enable               # Ensure that Yarn is installed\n$ yarn install                  # Install dependencies\n$ yarn start                    # Launch Node.js app with \"live-reload\"\n$ yarn build                    # Build the app for production\n$ yarn test                     # Run unit tests\n```\n\nTo add a new route create a new `.ts` file under `./routes` folder, e.g. `./routes/posts/[id].ts`, with the following signature:\n\n```ts\nimport { HttpFunction } from \"@google-cloud/functions-framework\";\n\n/**\n * Fetches a post by ID.\n *\n * @example GET /api/posts/1\n */\nexport const GET: HttpFunction = async (req, res) =\u003e {\n  const url = `https://jsonplaceholder.typicode.com/posts/${req.params.id}`;\n  const fetchRes = await fetch(url);\n  const post = await fetchRes.json();\n  res.send(post);\n};\n```\n\nTo create a unit test for it, create a new `.test.ts` file next to it, e.g. `./routes/posts/[id].test.ts`. For example:\n\n```ts\nimport { getTestServer } from \"@google-cloud/functions-framework/testing\";\nimport supertest from \"supertest\";\nimport { expect, test } from \"vitest\";\nimport { functionName } from \"../../index\";\n\ntest(\"GET /api/posts/1\", async () =\u003e {\n  const api = getTestServer(functionName);\n  const res = await supertest(api)\n    .get(\"/api/posts/1\")\n    .set(\"Accept\", \"application/json\");\n\n  expect({\n    statusCode: res.statusCode,\n    body: res.body,\n  }).toEqual({\n    statusCode: 200,\n    body: {\n      id: 1,\n      userId: 1,\n      title:\n        \"sunt aut facere repellat provident occaecati excepturi optio reprehenderit\",\n      body:\n        \"quia et suscipit\\nsuscipit recusandae consequuntur expedita et cum\\nreprehenderit \" +\n        \"molestiae ut ut quas totam\\nnostrum rerum est autem sunt rem eveniet architecto\",\n    },\n  });\n});\n```\n\n## References\n\n- https://vitejs.dev/guide/features.html#glob-import\n- https://github.com/pillarjs/path-to-regexp#readme\n\n## Backers\n\n\u003ca href=\"https://reactstarter.com/b/1\"\u003e\u003cimg src=\"https://reactstarter.com/b/1.png\" height=\"60\" /\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u003ca href=\"https://reactstarter.com/b/2\"\u003e\u003cimg src=\"https://reactstarter.com/b/2.png\" height=\"60\" /\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u003ca href=\"https://reactstarter.com/b/3\"\u003e\u003cimg src=\"https://reactstarter.com/b/3.png\" height=\"60\" /\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u003ca href=\"https://reactstarter.com/b/4\"\u003e\u003cimg src=\"https://reactstarter.com/b/4.png\" height=\"60\" /\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u003ca href=\"https://reactstarter.com/b/5\"\u003e\u003cimg src=\"https://reactstarter.com/b/5.png\" height=\"60\" /\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u003ca href=\"https://reactstarter.com/b/6\"\u003e\u003cimg src=\"https://reactstarter.com/b/6.png\" height=\"60\" /\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u003ca href=\"https://reactstarter.com/b/7\"\u003e\u003cimg src=\"https://reactstarter.com/b/7.png\" height=\"60\" /\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u003ca href=\"https://reactstarter.com/b/8\"\u003e\u003cimg src=\"https://reactstarter.com/b/8.png\" height=\"60\" /\u003e\u003c/a\u003e\n\n## License\n\nCopyright © 2023-present Konstantin Tarkus. This source code is licensed under the MIT license found in the [LICENSE](https://github.com/koistya/cloud-functions-routing/blob/main/LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoistya%2Fcloud-functions-routing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoistya%2Fcloud-functions-routing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoistya%2Fcloud-functions-routing/lists"}