{"id":19834158,"url":"https://github.com/someimportantcompany/koa-vhost","last_synced_at":"2026-05-10T12:15:02.193Z","repository":{"id":42659180,"uuid":"354295442","full_name":"someimportantcompany/koa-vhost","owner":"someimportantcompany","description":"Virtual host splitting for Koa.js v2","archived":false,"fork":false,"pushed_at":"2023-01-07T06:27:56.000Z","size":503,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-25T17:22:20.200Z","etag":null,"topics":["koa","koa2","koajs","vhosts"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/someimportantcompany.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-04-03T13:11:05.000Z","updated_at":"2023-03-03T11:44:32.000Z","dependencies_parsed_at":"2023-02-06T14:00:40.473Z","dependency_job_id":null,"html_url":"https://github.com/someimportantcompany/koa-vhost","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someimportantcompany%2Fkoa-vhost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someimportantcompany%2Fkoa-vhost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someimportantcompany%2Fkoa-vhost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someimportantcompany%2Fkoa-vhost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/someimportantcompany","download_url":"https://codeload.github.com/someimportantcompany/koa-vhost/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241198976,"owners_count":19926554,"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":["koa","koa2","koajs","vhosts"],"created_at":"2024-11-12T12:03:24.251Z","updated_at":"2026-05-10T12:15:02.186Z","avatar_url":"https://github.com/someimportantcompany.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM](https://badge.fury.io/js/%40someimportantcompany%2Fkoa-vhost.svg)](https://npm.im/@someimportantcompany/koa-vhost)\n[![CI](https://github.com/someimportantcompany/koa-vhost/actions/workflows/ci.yml/badge.svg)](https://github.com/someimportantcompany/koa-vhost/actions/workflows/ci.yml)\n[![Coverage](https://coveralls.io/repos/github/someimportantcompany/koa-vhost/badge.svg)](https://coveralls.io/github/someimportantcompany/koa-vhost)\n\n\u003e [!WARNING]\n\u003e **No longer maintained**\n\nVirtual host splitting for [Koa.js](https://koajs.com) v2.\n\n## Install\n\n```\n$ npm install --save @someimportantcompany/koa-vhost\n```\n\n## Usage\n\n```js\nconst Koa = require('koa');\nconst vhost = require('@someimportantcompany/koa-vhost');\n\nconst app = new Koa();\n\napp.use(vhost('s1.example.com', ctx =\u003e {\n  ctx.status = 200;\n  ctx.body = 'server s1';\n}));\n\napp.use(vhost(/(s2|s3).example.com/, ctx =\u003e {\n  ctx.status = 200;\n  ctx.body = 'server s2 or s3';\n}));\n\napp.use(vhost([ 's4.example.com', 's5.example.com' ], ctx =\u003e {\n  ctx.status = 200;\n  ctx.body = 'server s4 or s5';\n}));\n\napp.use(vhost('t2.example.com', ctx =\u003e {\n  ctx.status = 200;\n  ctx.body = 'server t2';\n}));\n\napp.use(ctx =\u003e {\n  ctx.status = 200;\n  ctx.body = 'generic server';\n});\n\napp.listen(3000);\n```\n\nThen, assuming [httpie](https://httpie.io/):\n\n```\n$ http --print=HhBb http://localhost:54321\nGET / HTTP/1.1\nAccept: */*\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\nHost: localhost:54321\nUser-Agent: HTTPie/1.0.3\n\n\nHTTP/1.1 200 OK\nConnection: keep-alive\nContent-Length: 14\nContent-Type: text/plain; charset=utf-8\nDate: Sat, 03 Apr 2021 12:47:33 GMT\nKeep-Alive: timeout=5\n\ngeneric server\n```\n\n```\n$ http --print=HhBb http://localhost:54321 Host:s1.example.com\nGET / HTTP/1.1\nAccept: */*\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\nHost: s1.example.com\nUser-Agent: HTTPie/1.0.3\n\nHTTP/1.1 200 OK\nConnection: keep-alive\nContent-Length: 9\nContent-Type: text/plain; charset=utf-8\nDate: Sat, 03 Apr 2021 12:48:43 GMT\nKeep-Alive: timeout=5\n\nserver s1\n```\n\n```\n$ http --print=HhBb http://localhost:54321 Host:s2.example.com\nGET / HTTP/1.1\nAccept: */*\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\nHost: s1.example.com\nUser-Agent: HTTPie/1.0.3\n\nHTTP/1.1 200 OK\nConnection: keep-alive\nContent-Length: 9\nContent-Type: text/plain; charset=utf-8\nDate: Sat, 03 Apr 2021 12:48:43 GMT\nKeep-Alive: timeout=5\n\nserver s2 or s3\n```\n\n## API\n\n### `vhost(hosts, middleware)`\n\nOption | Description\n---- | ----\n`hosts` | Either a `Function`, `Array`, `RegExp` or `String` of the hosts to match.\n`middleware` | Middleware `Function` to execute if the hostname matches.\n\n## Notes\n\n- Any questions or suggestions please [open an issue](https://github.com/someimportantcompany/koa-vhost/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomeimportantcompany%2Fkoa-vhost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomeimportantcompany%2Fkoa-vhost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomeimportantcompany%2Fkoa-vhost/lists"}