{"_id":"koa-history-api-fallback","_rev":"1213822","name":"koa-history-api-fallback","description":"Provides a fallback for non-existing directories so that the HTML 5 history API can be used for Koa.","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"dalhorinek","email":"dal@horinek.net"}],"time":{"modified":"2021-10-13T05:46:57.000Z","created":"2015-12-30T00:20:11.705Z","1.0.0":"2019-05-10T13:14:38.032Z","0.2.0":"2019-04-03T05:57:15.824Z","0.1.3":"2015-12-30T12:47:58.224Z","0.1.2":"2015-12-30T12:46:54.814Z","0.1.1":"2015-12-30T00:25:06.031Z","0.1.0":"2015-12-30T00:20:11.705Z"},"users":{},"author":{"name":"Dalibor Horinek","email":"dal@horinek.net","url":"http://www.horinek.net"},"repository":{"type":"git","url":"git+https://github.com/dalhorinek/koa-history-api-fallback.git"},"versions":{"1.0.0":{"name":"koa-history-api-fallback","version":"1.0.0","description":"Provides a fallback for non-existing directories so that the HTML 5 history API can be used for Koa.","keyswords":["koa","connect","html5","history api","fallback","spa"],"engines":{"node":">=0.8"},"main":"lib/index.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/dalhorinek/koa-history-api-fallback.git"},"author":{"name":"Dalibor Horinek","email":"dal@horinek.net","url":"http://www.horinek.net"},"contributors":[{"name":"Ben Ripkens","email":"bripkens.dev@gmail.com","url":"http://bripkens.de"},{"name":"Craig Myles","email":"cr@igmyles.com","url":"http://www.craigmyles.com"}],"license":"MIT","gitHead":"f60826c3b0bc415c42806b73a1138765e353781b","bugs":{"url":"https://github.com/dalhorinek/koa-history-api-fallback/issues"},"homepage":"https://github.com/dalhorinek/koa-history-api-fallback#readme","_id":"koa-history-api-fallback@1.0.0","_npmVersion":"6.1.0","_nodeVersion":"9.11.2","_npmUser":{"name":"dalhorinek","email":"dal@horinek.net"},"dist":{"shasum":"b232e7d118d0dd5afeea3613c649608d9b0f9087","size":3596,"noattachment":false,"key":"/koa-history-api-fallback/-/koa-history-api-fallback-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/koa-history-api-fallback/download/koa-history-api-fallback-1.0.0.tgz"},"maintainers":[{"name":"dalhorinek","email":"dal@horinek.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-history-api-fallback_1.0.0_1557494077872_0.47459619715615475"},"_hasShrinkwrap":false,"publish_time":1557494078032,"_cnpm_publish_time":1557494078032},"0.2.0":{"name":"koa-history-api-fallback","version":"0.2.0","description":"Provides a fallback for non-existing directories so that the HTML 5 history API can be used for Koa.","keyswords":["koa","connect","html5","history api","fallback","spa"],"engines":{"node":">=0.8"},"main":"lib/index.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/dalhorinek/koa-history-api-fallback.git"},"author":{"name":"Dalibor Horinek","email":"dal@horinek.net","url":"http://www.horinek.net"},"contributors":[{"name":"Ben Ripkens","email":"bripkens.dev@gmail.com","url":"http://bripkens.de"},{"name":"Craig Myles","email":"cr@igmyles.com","url":"http://www.craigmyles.com"}],"license":"MIT","gitHead":"0dbb433461940b23fc727c4549a51f32d516503e","bugs":{"url":"https://github.com/dalhorinek/koa-history-api-fallback/issues"},"homepage":"https://github.com/dalhorinek/koa-history-api-fallback#readme","_id":"koa-history-api-fallback@0.2.0","_npmVersion":"6.1.0","_nodeVersion":"9.11.2","_npmUser":{"name":"dalhorinek","email":"dal@horinek.net"},"dist":{"shasum":"39a9b027c6846d26b17ff853ba8b17500f62efbd","size":3581,"noattachment":false,"key":"/koa-history-api-fallback/-/koa-history-api-fallback-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/koa-history-api-fallback/download/koa-history-api-fallback-0.2.0.tgz"},"maintainers":[{"name":"dalhorinek","email":"dal@horinek.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-history-api-fallback_0.2.0_1554271035582_0.7900734051281804"},"_hasShrinkwrap":false,"publish_time":1554271035824,"_cnpm_publish_time":1554271035824},"0.1.3":{"name":"koa-history-api-fallback","version":"0.1.3","description":"Provides a fallback for non-existing directories so that the HTML 5 history API can be used for Koa.","keyswords":["koa","connect","html5","history api","fallback","spa"],"engines":{"node":">=0.8"},"main":"lib/index.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/dalhorinek/koa-history-api-fallback.git"},"author":{"name":"Dalibor Horinek","email":"dal@horinek.net","url":"http://www.horinek.net"},"contributors":[{"name":"Ben Ripkens","email":"bripkens.dev@gmail.com","url":"http://bripkens.de"},{"name":"Craig Myles","email":"cr@igmyles.com","url":"http://www.craigmyles.com"}],"license":"MIT","gitHead":"f4ba510a4f384fa3ec8b110787f0b1a084ed553f","bugs":{"url":"https://github.com/dalhorinek/koa-history-api-fallback/issues"},"homepage":"https://github.com/dalhorinek/koa-history-api-fallback#readme","_id":"koa-history-api-fallback@0.1.3","_shasum":"94eb35b481914d682634f9911021187667f02b39","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"dalhorinek","email":"dal@horinek.net"},"dist":{"shasum":"94eb35b481914d682634f9911021187667f02b39","size":3715,"noattachment":false,"key":"/koa-history-api-fallback/-/koa-history-api-fallback-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/koa-history-api-fallback/download/koa-history-api-fallback-0.1.3.tgz"},"maintainers":[{"name":"dalhorinek","email":"dal@horinek.net"}],"directories":{},"publish_time":1451479678224,"_cnpm_publish_time":1451479678224,"_hasShrinkwrap":false},"0.1.2":{"name":"koa-history-api-fallback","version":"0.1.2","description":"Provides a fallback for non-existing directories so that the HTML 5 history API can be used for Koa.","keyswords":["koa","connect","html5","history api","fallback","spa"],"engines":{"node":">=0.8"},"main":"lib/index.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/dalhorinek/koa-connect-history-api-fallback.git"},"author":{"name":"Dalibor Horinek","email":"dal@horinek.net","url":"http://www.horinek.net"},"contributors":[{"name":"Ben Ripkens","email":"bripkens.dev@gmail.com","url":"http://bripkens.de"},{"name":"Craig Myles","email":"cr@igmyles.com","url":"http://www.craigmyles.com"}],"license":"MIT","gitHead":"b903a723a8e20fb5b9b7de1b2f474fc13f782574","bugs":{"url":"https://github.com/dalhorinek/koa-connect-history-api-fallback/issues"},"homepage":"https://github.com/dalhorinek/koa-connect-history-api-fallback#readme","_id":"koa-history-api-fallback@0.1.2","_shasum":"f69b567f9f8dd3d5ad96972afc877234d8c9e1f4","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"dalhorinek","email":"dal@horinek.net"},"dist":{"shasum":"f69b567f9f8dd3d5ad96972afc877234d8c9e1f4","size":3714,"noattachment":false,"key":"/koa-history-api-fallback/-/koa-history-api-fallback-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/koa-history-api-fallback/download/koa-history-api-fallback-0.1.2.tgz"},"maintainers":[{"name":"dalhorinek","email":"dal@horinek.net"}],"directories":{},"publish_time":1451479614814,"_cnpm_publish_time":1451479614814,"_hasShrinkwrap":false},"0.1.1":{"name":"koa-history-api-fallback","version":"0.1.1","description":"Provides a fallback for non-existing directories so that the HTML 5 history API can be used for Koa.","keyswords":["koa","connect","html5","history api","fallback","spa"],"engines":{"node":">=0.8"},"main":"lib/index.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/dalhorinek/koa-connect-history-api-fallback.git"},"author":{"name":"Dalibor Horinek","email":"dal@horinek.net","url":"http://www.horinek.net"},"contributors":[{"name":"Ben Ripkens","email":"bripkens.dev@gmail.com","url":"http://bripkens.de"},{"name":"Craig Myles","email":"cr@igmyles.com","url":"http://www.craigmyles.com"}],"license":"MIT","gitHead":"d31fafccc9d9009b20a466db7fd29c226e174fd3","bugs":{"url":"https://github.com/dalhorinek/koa-connect-history-api-fallback/issues"},"homepage":"https://github.com/dalhorinek/koa-connect-history-api-fallback#readme","_id":"koa-history-api-fallback@0.1.1","_shasum":"7a64e516cacc26c8ed2095b2b2dcc39a0a946223","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"dalhorinek","email":"dal@horinek.net"},"dist":{"shasum":"7a64e516cacc26c8ed2095b2b2dcc39a0a946223","size":3736,"noattachment":false,"key":"/koa-history-api-fallback/-/koa-history-api-fallback-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/koa-history-api-fallback/download/koa-history-api-fallback-0.1.1.tgz"},"maintainers":[{"name":"dalhorinek","email":"dal@horinek.net"}],"directories":{},"publish_time":1451435106031,"_cnpm_publish_time":1451435106031,"_hasShrinkwrap":false},"0.1.0":{"name":"koa-history-api-fallback","version":"0.1.0","description":"Provides a fallback for non-existing directories so that the HTML 5 history API can be used for Koa.","keyswords":["koa","connect","html5","history api","fallback","spa"],"engines":{"node":">=0.8"},"main":"lib/index.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/dalhorinek/koa-connect-history-api-fallback.git"},"author":{"name":"Dalibor Horinek","email":"dal@horinek.net","url":"http://www.horinek.net"},"contributors":[{"name":"Ben Ripkens","email":"bripkens.dev@gmail.com","url":"http://bripkens.de"},{"name":"Craig Myles","email":"cr@igmyles.com","url":"http://www.craigmyles.com"}],"license":"MIT","gitHead":"5f699b6e707e303253e7a8a9fc74f103be3985fe","bugs":{"url":"https://github.com/dalhorinek/koa-connect-history-api-fallback/issues"},"homepage":"https://github.com/dalhorinek/koa-connect-history-api-fallback#readme","_id":"koa-history-api-fallback@0.1.0","_shasum":"7d01ea29ad4248c03eeb42cbd069083fda4b0390","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"dalhorinek","email":"dal@horinek.net"},"dist":{"shasum":"7d01ea29ad4248c03eeb42cbd069083fda4b0390","size":3735,"noattachment":false,"key":"/koa-history-api-fallback/-/koa-history-api-fallback-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/koa-history-api-fallback/download/koa-history-api-fallback-0.1.0.tgz"},"maintainers":[{"name":"dalhorinek","email":"dal@horinek.net"}],"directories":{},"publish_time":1451434811705,"_cnpm_publish_time":1451434811705,"_hasShrinkwrap":false}},"readme":" Version 1.0.0 includes fix for koa v3.\n\n<h1 align=\"center\">koa-history-api-fallback</h1>\n<p align=\"center\">Koa implementation of [connect-history-api-fallback](https://github.com/bripkens/connect-history-api-fallback)\n\n[![NPM](https://nodei.co/npm/koa-history-api-fallback.png?downloads=true&downloadRank=true)](https://nodei.co/npm/koa-history-api-fallback/)\n\n## Introduction\n\nThis is simple rewrite of [connect-history-api-fallback](https://github.com/bripkens/connect-history-api-fallback)\n\n## Usage\n\nThe middleware is available through NPM and can easily be added.\n\n```\nnpm install --save koa-history-api-fallback\n```\n\nImport the library\n\n```javascript\nvar historyApiFallback = require('koa-history-api-fallback');\n\nvar app = koa();\n\napp.use(historyApiFallback());\n```\n\n## Options\nYou can optionally pass options to the library when obtaining the middleware\n\n```javascript\nvar middleware = historyApiFallback({});\n```\n\n### index\nOverride the index (default `/index.html`)\n\n```javascript\nhistoryApiFallback({\n  index: '/default.html'\n});\n```\n\n### rewrites\nOverride the index when the request url matches a regex pattern. You can either rewrite to a static string or use a function to transform the incoming request.\n\nThe following will rewrite a request that matches the `/\\/soccer/` pattern to `/soccer.html`.\n```javascript\nhistoryApiFallback({\n  rewrites: [\n    { from: /\\/soccer/, to: '/soccer.html'}\n  ]\n});\n```\n\nAlternatively functions can be used to have more control over the rewrite process. For instance, the following listing shows how requests to `/libs/jquery/jquery.1.12.0.min.js` and the like can be routed to `./bower_components/libs/jquery/jquery.1.12.0.min.js`. You can also make use of this if you have an API version in the URL path.\n```javascript\nhistoryApiFallback({\n  rewrites: [\n    {\n      from: /^\\/libs\\/.*$/,\n      to: function(context) {\n        return '/bower_components' + context.parsedUrl.pathname;\n      }\n    }\n  ]\n});\n```\n\nThe function will always be called with a context object that has the following properties:\n\n - **parsedUrl**: Information about the URL as provided by the [URL module's](https://nodejs.org/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost) `url.parse`.\n - **match**: An Array of matched results as provided by `String.match(...)`.\n\n\n### verbose\nThis middleware does not log any information by default. If you wish to activate logging, then you can do so via the `verbose` option or by specifying a logger function.\n\n```javascript\nhistoryApiFallback({\n  verbose: true\n});\n```\n\nAlternatively use your own logger\n\n```javascript\nhistoryApiFallback({\n  logger: console.log.bind(console)\n});\n```\n","_attachments":{},"homepage":"https://github.com/dalhorinek/koa-history-api-fallback#readme","bugs":{"url":"https://github.com/dalhorinek/koa-history-api-fallback/issues"},"license":"MIT"}