{"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","tarball":"http://registry-npm.ywwl.com/express-history-api-fallback/download/express-history-api-fallback-2.1.0.tgz","integrity":"sha512-/hFP41m4SBwfzDFpLepN17fIP8wTqBJVm5/RozAFIJYSkpIGozY7Y3DkjkzI5+eZW4VVUsVsfQoPzgNF4IsLOQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGvCql7NotYndjRxCzCirHVfMkdK5IkiI4iwC2C7dtSNAiBRfUeEkQp0IwO3IgPktYTCacvdErLd26L3ZsIpF9abiQ=="}],"size":2587,"noattachment":false,"key":"/express-history-api-fallback/-/express-history-api-fallback-2.1.0.tgz"},"maintainers":[{"name":"seb","email":"seb@ninja.sg"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/express-history-api-fallback-2.1.0.tgz_1481792805878_0.715644568670541"},"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":1481792806103,"_cnpm_publish_time":1481792806103,"dist-tags":{"latest":"2.2.1"}}