{ "_args": [ [ { "raw": "finalhandler@1.1.0", "scope": null, "escapedName": "finalhandler", "name": "finalhandler", "rawSpec": "1.1.0", "spec": "1.1.0", "type": "version" }, "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/express" ] ], "_from": "finalhandler@1.1.0", "_id": "finalhandler@1.1.0", "_inCache": true, "_location": "/finalhandler", "_nodeVersion": "6.11.1", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/finalhandler-1.1.0.tgz_1506311584388_0.4006447312422097" }, "_npmUser": { "name": "dougwilson", "email": "doug@somethingdoug.com" }, "_npmVersion": "3.10.10", "_phantomChildren": {}, "_requested": { "raw": "finalhandler@1.1.0", "scope": null, "escapedName": "finalhandler", "name": "finalhandler", "rawSpec": "1.1.0", "spec": "1.1.0", "type": "version" }, "_requiredBy": [ "/express" ], "_resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", "_shasum": "ce0b6855b45853e791b2fcc680046d88253dd7f5", "_shrinkwrap": null, "_spec": "finalhandler@1.1.0", "_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/express", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, "bugs": { "url": "https://github.com/pillarjs/finalhandler/issues" }, "dependencies": { "debug": "2.6.9", "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "on-finished": "~2.3.0", "parseurl": "~1.3.2", "statuses": "~1.3.1", "unpipe": "~1.0.0" }, "description": "Node.js final http responder", "devDependencies": { "eslint": "3.19.0", "eslint-config-standard": "10.2.1", "eslint-plugin-import": "2.7.0", "eslint-plugin-markdown": "1.0.0-beta.6", "eslint-plugin-node": "5.1.1", "eslint-plugin-promise": "3.5.0", "eslint-plugin-standard": "3.0.1", "istanbul": "0.4.5", "mocha": "2.5.3", "readable-stream": "2.3.3", "safe-buffer": "5.1.1", "supertest": "1.1.0" }, "directories": {}, "dist": { "shasum": "ce0b6855b45853e791b2fcc680046d88253dd7f5", "tarball": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz" }, "engines": { "node": ">= 0.8" }, "files": [ "LICENSE", "HISTORY.md", "index.js" ], "gitHead": "a49efb83a3363d895f8c2a4cad07ccfc9e90b8ef", "homepage": "https://github.com/pillarjs/finalhandler#readme", "license": "MIT", "maintainers": [ { "name": "dougwilson", "email": "doug@somethingdoug.com" } ], "name": "finalhandler", "optionalDependencies": {}, "readme": "# finalhandler\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Node.js Version][node-image]][node-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\nNode.js function to invoke as the final step to respond to HTTP request.\n\n## Installation\n\nThis is a [Node.js](https://nodejs.org/en/) module available through the\n[npm registry](https://www.npmjs.com/). Installation is done using the\n[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):\n\n```sh\n$ npm install finalhandler\n```\n\n## API\n\n\n\n```js\nvar finalhandler = require('finalhandler')\n```\n\n### finalhandler(req, res, [options])\n\nReturns function to be invoked as the final step for the given `req` and `res`.\nThis function is to be invoked as `fn(err)`. If `err` is falsy, the handler will\nwrite out a 404 response to the `res`. If it is truthy, an error response will\nbe written out to the `res`.\n\nWhen an error is written, the following information is added to the response:\n\n * The `res.statusCode` is set from `err.status` (or `err.statusCode`). If\n this value is outside the 4xx or 5xx range, it will be set to 500.\n * The `res.statusMessage` is set according to the status code.\n * The body will be the HTML of the status code message if `env` is\n `'production'`, otherwise will be `err.stack`.\n * Any headers specified in an `err.headers` object.\n\nThe final handler will also unpipe anything from `req` when it is invoked.\n\n#### options.env\n\nBy default, the environment is determined by `NODE_ENV` variable, but it can be\noverridden by this option.\n\n#### options.onerror\n\nProvide a function to be called with the `err` when it exists. Can be used for\nwriting errors to a central location without excessive function generation. Called\nas `onerror(err, req, res)`.\n\n## Examples\n\n### always 404\n\n```js\nvar finalhandler = require('finalhandler')\nvar http = require('http')\n\nvar server = http.createServer(function (req, res) {\n var done = finalhandler(req, res)\n done()\n})\n\nserver.listen(3000)\n```\n\n### perform simple action\n\n```js\nvar finalhandler = require('finalhandler')\nvar fs = require('fs')\nvar http = require('http')\n\nvar server = http.createServer(function (req, res) {\n var done = finalhandler(req, res)\n\n fs.readFile('index.html', function (err, buf) {\n if (err) return done(err)\n res.setHeader('Content-Type', 'text/html')\n res.end(buf)\n })\n})\n\nserver.listen(3000)\n```\n\n### use with middleware-style functions\n\n```js\nvar finalhandler = require('finalhandler')\nvar http = require('http')\nvar serveStatic = require('serve-static')\n\nvar serve = serveStatic('public')\n\nvar server = http.createServer(function (req, res) {\n var done = finalhandler(req, res)\n serve(req, res, done)\n})\n\nserver.listen(3000)\n```\n\n### keep log of all errors\n\n```js\nvar finalhandler = require('finalhandler')\nvar fs = require('fs')\nvar http = require('http')\n\nvar server = http.createServer(function (req, res) {\n var done = finalhandler(req, res, {onerror: logerror})\n\n fs.readFile('index.html', function (err, buf) {\n if (err) return done(err)\n res.setHeader('Content-Type', 'text/html')\n res.end(buf)\n })\n})\n\nserver.listen(3000)\n\nfunction logerror (err) {\n console.error(err.stack || err.toString())\n}\n```\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/finalhandler.svg\n[npm-url]: https://npmjs.org/package/finalhandler\n[node-image]: https://img.shields.io/node/v/finalhandler.svg\n[node-url]: https://nodejs.org/en/download\n[travis-image]: https://img.shields.io/travis/pillarjs/finalhandler.svg\n[travis-url]: https://travis-ci.org/pillarjs/finalhandler\n[coveralls-image]: https://img.shields.io/coveralls/pillarjs/finalhandler.svg\n[coveralls-url]: https://coveralls.io/r/pillarjs/finalhandler?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/finalhandler.svg\n[downloads-url]: https://npmjs.org/package/finalhandler\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/pillarjs/finalhandler.git" }, "scripts": { "lint": "eslint --plugin markdown --ext js,md .", "test": "mocha --reporter spec --bail --check-leaks test/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, "version": "1.1.0" }