{"id":23510877,"url":"https://github.com/danielkov/koa-spa-hashless-route","last_synced_at":"2025-05-13T17:17:44.093Z","repository":{"id":98242195,"uuid":"76023481","full_name":"danielkov/koa-spa-hashless-route","owner":"danielkov","description":"Koa JS middleware for hashless routes via pushstate for single page applications.","archived":false,"fork":false,"pushed_at":"2016-12-09T10:50:15.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T22:02:02.313Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielkov.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2016-12-09T09:56:00.000Z","updated_at":"2022-12-20T12:34:42.000Z","dependencies_parsed_at":"2023-05-18T22:15:44.288Z","dependency_job_id":null,"html_url":"https://github.com/danielkov/koa-spa-hashless-route","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Fkoa-spa-hashless-route","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Fkoa-spa-hashless-route/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Fkoa-spa-hashless-route/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Fkoa-spa-hashless-route/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielkov","download_url":"https://codeload.github.com/danielkov/koa-spa-hashless-route/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990506,"owners_count":21995776,"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-12-25T12:12:41.624Z","updated_at":"2025-05-13T17:17:44.082Z","avatar_url":"https://github.com/danielkov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Koa Hashless Route\n\nThis is a Koa JS middleware for hashless routing of single page applications.\n\n### What it does\n\nIt's built on top of [koa-send](https://github.com/koajs/send) and so it uses the options object with the same exact setup.\n\nIt routes all requests made to a file with the mimetype specified by the `allowedMimeTypes` array to the corresponding file, while redirects all other requests to the index page specified by the `index` parameter. This will allow for pretty urls inside your single page application, such as one built with [AngularJS](https://angularjs.org/).\n\n### Example usage\n\nThis example allows for an api to exist at the end-point: `www.yourwebsite.com/api` while all other requests like `www.yourwebsite.com/something/awesome/here` will redirect to `index.html` while maintaining the parameters passed in the url, like `something`, `awesome` and `here`.\n\n```js\nconst app = require('koa')();\nconst router = require('koa-router')();\nconst hashlessRoute = require('koa-spa-hashless-route');\n\nrouter\n.use('/api', apiRoutes.routes(), apiRoutes.allowedMethods())\n.use('/', hashlessRoute(['png', 'gif', 'jpeg', 'js', 'css'], 'index.html', { root: __dirname + '/../dist' }));\n\napp\n.use(router.routes())\n.use(router.allowedMethods());\n\napp.listen(3000);\n\n```\n\nFor more options see [koa-send](https://github.com/koajs/send) documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielkov%2Fkoa-spa-hashless-route","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielkov%2Fkoa-spa-hashless-route","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielkov%2Fkoa-spa-hashless-route/lists"}