{"_id":"express-history-api-fallback","_rev":"8256","name":"express-history-api-fallback","description":"Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.","dist-tags":{"latest":"2.2.1"},"maintainers":[{"name":"seb","email":""}],"time":{"modified":"2021-06-03T09:57:21.000Z","created":"2015-10-26T09:32:12.941Z","2.2.1":"2017-05-17T15:42:48.177Z","2.2.0":"2017-05-17T15:36:32.294Z","2.1.0":"2016-12-15T09:06:46.103Z","2.0.0":"2015-10-26T11:29:56.829Z","1.0.0":"2015-10-26T09:32:12.941Z"},"users":{"amongiants":true},"author":{"name":"Sebastiaan Deckers","email":"sebdeckers83@gmail.com"},"repository":{"type":"git","url":"git+https://gitlab.com/sebdeckers/express-history-api-fallback.git"},"versions":{"2.2.1":{"name":"express-history-api-fallback","version":"2.2.1","description":"Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.","main":"./dist","scripts":{"start":"npm run start-audit & npm run start-tdd","start-audit":"watch-spawn --initial --quiet --pattern 'package.json' npm run test-audit","start-tdd":"watch-spawn --initial --quiet --pattern '{lib,test}/**/*.js' npm run test-tdd","test":"npm run test-audit & npm run test-tdd","test-audit":"node-license-validator","test-tdd":"standard & npm run coverage","coverage":"babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha","prepublish":"npm run clean && npm test && npm run build","clean":"rimraf dist","build":"mkdirp dist && babel lib --out-file dist/index.js","codecov":"cat coverage/coverage.json | codecov"},"repository":{"type":"git","url":"git+https://gitlab.com/sebdeckers/express-history-api-fallback.git"},"keywords":["express","html5","history api","fallback","spa","middleware","connect","pushstate","popstate","single page app","router","client side"],"author":{"name":"Sebastiaan Deckers","email":"sebdeckers83@gmail.com"},"license":"ISC","bugs":{"url":"https://gitlab.com/sebdeckers/express-history-api-fallback/issues"},"homepage":"https://gitlab.com/sebdeckers/express-history-api-fallback#readme","devDependencies":{"babel":"^5.8.29","babel-eslint":"^4.1.3","chai":"^3.4.0","codecov.io":"^0.1.6","isparta":"^3.1.0","mkdirp":"^0.5.1","mocha":"^2.3.3","node-license-validator":"^1.2.1","rimraf":"^2.4.3","sinon":"^1.17.2","sinon-chai":"^2.8.0","standard":"^5.3.1","watch-spawn":"^1.0.6"},"standard":{"parser":"babel-eslint"},"gitHead":"13aa6fb15ddd6d39dc5e623937256c2e789dcc53","_id":"express-history-api-fallback@2.2.1","_shasum":"3a2ad27f7bebc90fc533d110d7c6d83097bcd057","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"seb","email":"sebdeckers83@gmail.com"},"dist":{"shasum":"3a2ad27f7bebc90fc533d110d7c6d83097bcd057","size":2677,"noattachment":false,"key":"/express-history-api-fallback/-/express-history-api-fallback-2.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-history-api-fallback/download/express-history-api-fallback-2.2.1.tgz"},"maintainers":[{"name":"seb","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/express-history-api-fallback-2.2.1.tgz_1495035767934_0.38333291513845325"},"directories":{},"publish_time":1495035768177,"_hasShrinkwrap":false,"_cnpm_publish_time":1495035768177},"2.2.0":{"name":"express-history-api-fallback","version":"2.2.0","description":"Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.","main":"./dist","scripts":{"start":"npm run start-audit & npm run start-tdd","start-audit":"watch-spawn --initial --quiet --pattern 'package.json' npm run test-audit","start-tdd":"watch-spawn --initial --quiet --pattern '{lib,test}/**/*.js' npm run test-tdd","test":"npm run test-audit & npm run test-tdd","test-audit":"node-license-validator","test-tdd":"standard & npm run coverage","coverage":"babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha","prepublish":"npm run clean && npm test && npm run build","clean":"rimraf dist","build":"mkdirp dist && babel lib --out-file dist/index.js","codecov":"cat coverage/coverage.json | codecov"},"repository":{"type":"git","url":"git+https://github.com/cbas/express-history-api-fallback.git"},"keywords":["express","html5","history api","fallback","spa","middleware","connect","pushstate","popstate","single page app","router","client side"],"author":{"name":"Sebastiaan Deckers","email":"seb@ninja.sg"},"license":"ISC","bugs":{"url":"https://github.com/cbas/express-history-api-fallback/issues"},"homepage":"https://github.com/cbas/express-history-api-fallback#readme","devDependencies":{"babel":"^5.8.29","babel-eslint":"^4.1.3","chai":"^3.4.0","codecov.io":"^0.1.6","isparta":"^3.1.0","mkdirp":"^0.5.1","mocha":"^2.3.3","node-license-validator":"^1.2.1","rimraf":"^2.4.3","sinon":"^1.17.2","sinon-chai":"^2.8.0","standard":"^5.3.1","watch-spawn":"^1.0.6"},"standard":{"parser":"babel-eslint"},"gitHead":"288494720f2d164371d216c813d130b33a9527fb","_id":"express-history-api-fallback@2.2.0","_shasum":"3dbcb7423afa0e6ff94249112e332999c634a82c","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"seb","email":"sebdeckers83@gmail.com"},"dist":{"shasum":"3dbcb7423afa0e6ff94249112e332999c634a82c","size":2672,"noattachment":false,"key":"/express-history-api-fallback/-/express-history-api-fallback-2.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-history-api-fallback/download/express-history-api-fallback-2.2.0.tgz"},"maintainers":[{"name":"seb","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/express-history-api-fallback-2.2.0.tgz_1495035391992_0.7154691573232412"},"directories":{},"publish_time":1495035392294,"_hasShrinkwrap":false,"_cnpm_publish_time":1495035392294},"2.1.0":{"name":"express-history-api-fallback","version":"2.1.0","description":"Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.","main":"./dist","scripts":{"start":"npm run start-audit & npm run start-tdd","start-audit":"watch-spawn --initial --quiet --pattern 'package.json' npm run test-audit","start-tdd":"watch-spawn --initial --quiet --pattern '{lib,test}/**/*.js' npm run test-tdd","test":"npm run test-audit & npm run test-tdd","test-audit":"node-license-validator","test-tdd":"standard & npm run coverage","coverage":"babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha","prepublish":"npm run clean && npm test && npm run build","clean":"rimraf dist","build":"mkdirp dist && babel lib --out-file dist/index.js","codecov":"cat coverage/coverage.json | codecov"},"repository":{"type":"git","url":"git+https://github.com/cbas/express-history-api-fallback.git"},"keywords":["express","html5","history api","fallback","spa","middleware","connect","pushstate","popstate","single page app","router","client side"],"author":{"name":"Sebastiaan Deckers","email":"seb@ninja.sg"},"license":"ISC","bugs":{"url":"https://github.com/cbas/express-history-api-fallback/issues"},"homepage":"https://github.com/cbas/express-history-api-fallback#readme","devDependencies":{"babel":"^5.8.29","babel-eslint":"^4.1.3","chai":"^3.4.0","codecov.io":"^0.1.6","isparta":"^3.1.0","mkdirp":"^0.5.1","mocha":"^2.3.3","node-license-validator":"^1.2.1","rimraf":"^2.4.3","sinon":"^1.17.2","sinon-chai":"^2.8.0","standard":"^5.3.1","watch-spawn":"^1.0.6"},"standard":{"parser":"babel-eslint"},"gitHead":"2616ff8577afc8fcb30008dc61f0b54175eece50","_id":"express-history-api-fallback@2.1.0","_shasum":"3bed00cf8a3a3baa85c1d43357c28762eb6185ac","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.2.1","_npmUser":{"name":"seb","email":"sebdeckers83@gmail.com"},"dist":{"shasum":"3bed00cf8a3a3baa85c1d43357c28762eb6185ac","size":2587,"noattachment":false,"key":"/express-history-api-fallback/-/express-history-api-fallback-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-history-api-fallback/download/express-history-api-fallback-2.1.0.tgz"},"maintainers":[{"name":"seb","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/express-history-api-fallback-2.1.0.tgz_1481792805878_0.715644568670541"},"directories":{},"publish_time":1481792806103,"_cnpm_publish_time":1481792806103,"_hasShrinkwrap":false},"2.0.0":{"name":"express-history-api-fallback","version":"2.0.0","description":"Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.","main":"./dist","scripts":{"start":"npm run start-audit & npm run start-tdd","start-audit":"watch-spawn --initial --quiet --pattern 'package.json' npm run test-audit","start-tdd":"watch-spawn --initial --quiet --pattern '{lib,test}/**/*.js' npm run test-tdd","test":"npm run test-audit & npm run test-tdd","test-audit":"node-license-validator","test-tdd":"standard & npm run coverage","coverage":"babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha","prepublish":"npm run clean && npm test && npm run build","clean":"rimraf dist","build":"mkdirp dist && babel lib --out-file dist/index.js","codecov":"cat coverage/coverage.json | codecov"},"repository":{"type":"git","url":"git+https://github.com/cbas/express-history-api-fallback.git"},"keywords":["express","html5","history api","fallback","spa","middleware","connect","pushstate","popstate","single page app","router","client side"],"author":{"name":"Sebastiaan Deckers","email":"seb@ninja.sg"},"license":"ISC","bugs":{"url":"https://github.com/cbas/express-history-api-fallback/issues"},"homepage":"https://github.com/cbas/express-history-api-fallback#readme","devDependencies":{"babel":"^5.8.29","babel-eslint":"^4.1.3","chai":"^3.4.0","codecov.io":"^0.1.6","isparta":"^3.1.0","mkdirp":"^0.5.1","mocha":"^2.3.3","node-license-validator":"^1.2.1","rimraf":"^2.4.3","sinon":"^1.17.2","sinon-chai":"^2.8.0","standard":"^5.3.1","watch-spawn":"^1.0.6"},"standard":{"parser":"babel-eslint"},"gitHead":"badf8965b7ebffd29385f194d031e031f333b6cc","_id":"express-history-api-fallback@2.0.0","_shasum":"c7a47ffe30ee1a1ff6cf54c2bdc319d634991b2e","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.1","_npmUser":{"name":"seb","email":"seb@ninja.sg"},"dist":{"shasum":"c7a47ffe30ee1a1ff6cf54c2bdc319d634991b2e","size":2508,"noattachment":false,"key":"/express-history-api-fallback/-/express-history-api-fallback-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-history-api-fallback/download/express-history-api-fallback-2.0.0.tgz"},"maintainers":[{"name":"seb","email":""}],"directories":{},"publish_time":1445858996829,"_cnpm_publish_time":1445858996829,"_hasShrinkwrap":false},"1.0.0":{"name":"express-history-api-fallback","version":"1.0.0","description":"Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.","main":"./dist","scripts":{"start":"npm run start-audit & npm run start-tdd","start-audit":"watch-spawn --initial --quiet --pattern 'package.json' npm run test-audit","start-tdd":"watch-spawn --initial --quiet --pattern '{lib,test}/**/*.js' npm run test-tdd","test":"npm run test-audit & npm run test-tdd","test-audit":"node-license-validator","test-tdd":"standard & npm run coverage","coverage":"babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha","prepublish":"npm run clean && npm test && npm run build","clean":"rimraf dist","build":"mkdirp dist && babel lib --out-file dist/index.js","codecov":"cat coverage/coverage.json | codecov"},"repository":{"type":"git","url":"git+https://github.com/cbas/express-history-api-fallback.git"},"keywords":["express","html5","history api","fallback","spa","middleware","connect","pushstate","popstate","single page app","router","client side"],"author":{"name":"Sebastiaan Deckers","email":"seb@ninja.sg"},"license":"ISC","bugs":{"url":"https://github.com/cbas/express-history-api-fallback/issues"},"homepage":"https://github.com/cbas/express-history-api-fallback#readme","devDependencies":{"babel":"^5.8.29","babel-eslint":"^4.1.3","chai":"^3.4.0","codecov.io":"^0.1.6","express":"^4.13.3","isparta":"^3.1.0","mkdirp":"^0.5.1","mocha":"^2.3.3","node-license-validator":"^1.2.1","rimraf":"^2.4.3","sinon":"^1.17.2","sinon-chai":"^2.8.0","standard":"^5.3.1","watch-spawn":"^1.0.6"},"standard":{"parser":"babel-eslint"},"gitHead":"55880e14ff0624bfb4fd23a1a95c841f90050110","_id":"express-history-api-fallback@1.0.0","_shasum":"b1dc9be4d3d1c833d505af1c7b95fbd956e2ba98","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.1","_npmUser":{"name":"seb","email":"seb@ninja.sg"},"dist":{"shasum":"b1dc9be4d3d1c833d505af1c7b95fbd956e2ba98","size":1652,"noattachment":false,"key":"/express-history-api-fallback/-/express-history-api-fallback-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-history-api-fallback/download/express-history-api-fallback-1.0.0.tgz"},"maintainers":[{"name":"seb","email":""}],"directories":{},"publish_time":1445851932941,"_cnpm_publish_time":1445851932941,"_hasShrinkwrap":false}},"readme":"# express-history-api-fallback\nA tiny, accurate, fast Express middleware for single page apps with client side routing.\n\n[![Build Status](https://travis-ci.org/cbas/express-history-api-fallback.svg?branch=master)](https://travis-ci.org/cbas/express-history-api-fallback)\n[![codecov.io](https://codecov.io/github/cbas/express-history-api-fallback/coverage.svg?branch=master)](https://codecov.io/github/cbas/express-history-api-fallback?branch=master)\n\n[![NPM](https://nodei.co/npm/express-history-api-fallback.png)](https://www.npmjs.com/package/express-history-api-fallback)\n\nWorks as a middleware for Express. Can be used as either an application middleware or a router middleware.\n\n```js\nimport fallback from 'express-history-api-fallback'\nimport express from 'express'\nconst app = express()\nconst root = `${__dirname}/public`\napp.use(express.static(root))\napp.use(fallback('index.html', { root }))\n```\nOr in ECMAScript 5:\n```js\nvar fallback = require('express-history-api-fallback')\nvar express = require('express')\nvar app = express()\nvar root = __dirname + '/public'\napp.use(express.static(root))\napp.use(fallback('index.html', { root: root }))\n```\n\n## fallback(path[, options])\nReturns a middleware for use by Express applications and routers.\n\nArguments are passed to [res.sendFile()](http://expressjs.com/api.html#res.sendFile) in `express@>=v4.8.0`, or [res.sendfile()](http://expressjs.com/en/3x/api.html#res.sendfile) otherwise.\n\nAbsolute path:\n```js\napp.use(fallback(__dirname + '/dist/app.html'))\n```\nRelative path:\n```js\napp.use(fallback('dist/app.html', { root: __dirname }))\n```\n\n### path\nLocation of the HTML file containing single page app entry point.\n\nUnless the `root` option is set in the `options` object, `path` must be an absolute path of the file.\n\n### options\nValid options are `maxAge`, `root`, `lastModified`, `headers`, and `dotfiles`. See [Response.sendFile()](http://expressjs.com/api.html#res.sendFile) for details. Note that only `maxAge` and `root` are supported with `express@<4.8`.\n\n## But doesn't this already exist?\nYes, but this implementation is much better.\n\n- **Only for GET (and HEAD) requests**: The fallback should not serve your `index.html` for `POST` or other requests.\n- **Only for HTML requests**: Never serve mistakenly for JS or CSS or image or other static file requests. Less debugging headaches.\n- **Only when needed**: Serve the fallback only when the file is missing.\n- **High performance**: Let `res.sendFile()` in Express `>=4.8.0` do the heavy lifting of serving the file.\n- **Minimal code**: Just a few lines. No magic. No complexity.\n\nSee the blog post [\"Single Page App Routing with Express & Node.js\"](https://ninja.sg/spa-router-fallback/) for an overview of the problems with alternative middlewares.\n","_attachments":{},"homepage":"https://gitlab.com/sebdeckers/express-history-api-fallback#readme","bugs":{"url":"https://gitlab.com/sebdeckers/express-history-api-fallback/issues"},"license":"ISC"}