{"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","tarball":"http://registry-npm.ywwl.com/express-history-api-fallback/download/express-history-api-fallback-1.0.0.tgz","integrity":"sha512-2x+7uLoWz3Bd17v4rS0jTRCoghH1cSJpJkNtlzZnVfLT+yHVf4JPUzlsVxWWGj0vJDU36ZTEU+wxWu34DHBu9A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD4Sj5b04gkDa19NEA5W6YzUWVO1WCvKcFqh2xlhG3tfgIhAOGIPfwl5K7V/4RbTKqY2h3X44KF/IJ2fuTo+4TQD6Lj"}],"size":1652,"noattachment":false,"key":"/express-history-api-fallback/-/express-history-api-fallback-1.0.0.tgz"},"maintainers":[{"name":"seb","email":"seb@ninja.sg"}],"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":1445851932941,"_cnpm_publish_time":1445851932941,"dist-tags":{"latest":"2.2.1"}}