{"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","tarball":"http://registry-npm.ywwl.com/express-history-api-fallback/download/express-history-api-fallback-2.2.1.tgz","integrity":"sha512-swxwm3aP8vrOOvlzOdZvHlSZtJGwHKaY94J6AkrAgCTmcbko3IRwbkhLv2wKV1WeZhjxX58aLMpP3atDBnKuZg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHAJnaPnKtJ/RNmJxbbEfcS4A4zVcH5fxZT7vjKPC+4zAiBrveZz4rCYVNxclhTo4sp4gbU6x1rWg8EVn8vy2eu/vQ=="}],"size":2677,"noattachment":false,"key":"/express-history-api-fallback/-/express-history-api-fallback-2.2.1.tgz"},"maintainers":[{"name":"seb","email":"seb@ninja.sg"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/express-history-api-fallback-2.2.1.tgz_1495035767934_0.38333291513845325"},"directories":{},"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","publish_time":1495035768177,"_cnpm_publish_time":1495035768177,"dist-tags":{"latest":"2.2.1"}}