{"_id":"koa-error-mapper","_rev":"17-253250931abbb46ee7a272a3092a181b","name":"koa-error-mapper","description":"An error mapper for Koa applications","dist-tags":{"latest":"4.1.0"},"versions":{"4.0.1":{"name":"koa-error-mapper","version":"4.0.1","description":"An error mapper for Koa applications","keywords":["error","koa","mappers","mapping"],"homepage":"https://github.com/uphold/koa-error-mapper","bugs":{"url":"https://github.com/uphold/koa-error-mapper/issues"},"license":"MIT","contributors":[{"name":"Francisco Cardoso","email":"comat8se@gmail.com","url":"https://github.com/franciscocardoso"},{"name":"Miguel Martins","email":"me@kurayama.net","url":"https://github.com/kurayama"},{"name":"Nuno Sousa","email":"nunofgs@gmail.com","url":"https://github.com/nunofgs"},{"name":"Ricardo Lopes","email":"mail@ricardolopes.net","url":"https://github.com/rplopes"},{"name":"Tiago Ribeiro","email":"tiago.ribeiro@gmail.com","url":"https://github.com/fixe"}],"repository":{"type":"git","url":"git+https://github.com/uphold/koa-error-mapper.git"},"scripts":{"changelog":"github-changelog-generator --owner=uphold --repo=koa-error-mapper --future-release=v$npm_package_version > CHANGELOG.md","lint":"eslint index.js mappers test","test":"jest --coverage","version":"npm run changelog && git add -A CHANGELOG.md"},"devDependencies":{"eslint":"^3.11.1","eslint-config-seegno":"^9.0.0","http-errors":"^1.3.1","jest":"^19.0.2","koa":"^2.0.1","pre-commit":"^1.1.2","supertest":"^3.0.0"},"engines":{"node":">= 7.6"},"pre-commit":["lint"],"gitHead":"b0e091f0047c0675af063739d2600151326a5169","_id":"koa-error-mapper@4.0.1","_shasum":"84ba46a853ba9978beb8d0f321da0fe7a78ea6ce","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.5","_npmUser":{"name":"uphold","email":"opensource@uphold.com"},"dist":{"shasum":"84ba46a853ba9978beb8d0f321da0fe7a78ea6ce","tarball":"https://registry.npmjs.org/koa-error-mapper/-/koa-error-mapper-4.0.1.tgz","integrity":"sha512-hA+zb/c7a+dUSXzWNC3bgVeJIZSzwVOV/c1CVZjm2u7EhtYLO3rM4JAnoEjNwooqXs+l+BZFFUixz6GS0G5SBA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC1YabiDJMu3Y/uPVP8DYfc8uy34ZsRfeRPphyP0NLp8AIgYPrWkMkYw5Ags7NnO41AlY5dq+mL0iabfe+9BQ4KLfE="}]},"maintainers":[{"name":"uphold","email":"opensource@uphold.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/koa-error-mapper-4.0.1.tgz_1490209288384_0.6393090311903507"},"directories":{}},"4.0.2":{"name":"koa-error-mapper","version":"4.0.2","description":"An error mapper for Koa applications","keywords":["error","koa","mappers","mapping"],"homepage":"https://github.com/uphold/koa-error-mapper","bugs":{"url":"https://github.com/uphold/koa-error-mapper/issues"},"license":"MIT","contributors":[{"name":"Francisco Cardoso","email":"comat8se@gmail.com","url":"https://github.com/franciscocardoso"},{"name":"Miguel Martins","email":"me@kurayama.net","url":"https://github.com/kurayama"},{"name":"Nuno Sousa","email":"nunofgs@gmail.com","url":"https://github.com/nunofgs"},{"name":"Ricardo Lopes","email":"mail@ricardolopes.net","url":"https://github.com/rplopes"},{"name":"Tiago Ribeiro","email":"tiago.ribeiro@gmail.com","url":"https://github.com/fixe"}],"repository":{"type":"git","url":"git+https://github.com/uphold/koa-error-mapper.git"},"scripts":{"changelog":"uphold-scripts changelog v$npm_package_version","lint":"uphold-scripts lint","release":"uphold-scripts release","test":"uphold-scripts test","version":"uphold-scripts version"},"pre-commit":["lint"],"jest":{"collectCoverageFrom":["mappers/**/*.js"]},"devDependencies":{"http-errors":"^1.7.3","koa":"^2.11.0","supertest":"^4.0.2","uphold-scripts":"^0.4.0"},"engines":{"node":">= 7.6"},"gitHead":"62abef44f75eabcd663b78d668dbc2a912b73f7b","_id":"koa-error-mapper@4.0.2","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-9NrKr37Fb74sLbVWPrzqU44aRZrS2eIzqFTvTfCKNpyoHxZI6qkMCcdrufgTr+yO0o++fh6y/TZCkN3cJvpd9g==","shasum":"76463ba4bc44b2cd4e6eac5836e439bb022b5f6d","tarball":"https://registry.npmjs.org/koa-error-mapper/-/koa-error-mapper-4.0.2.tgz","fileCount":7,"unpackedSize":10938,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqqHhCRA9TVsSAnZWagAAGm0P/inZ4UFNZoA9fMxCt6Tm\nqUMux+mZTQQAvfz48uJNeRl4kcbYlh0Z9fJARGqbZtCa2eLlujpxqwLeKf62\n4EUCjeD3QXyWiUWYNHI25KgGMa1yaAhERIB7kXyUgWAo7lPAiCkoUm3raOhp\nuxjOHGjlMezWdk5M/jrJ4Ee17XQOOuz/UKNBE6NrMAUsiihDUgb1wncIxXpY\nSeYWQmWLwBBXVkBODGYbLLMGb2wT8mAyDIa8wsmp2ZGlCPkLSvfgmad4IyFb\nq2sBg5yyXeB8xB3Vsfq6dNdpJyJneZH+gh38o5+EU1nMuAXohGV3ZgT2FjGo\n0CUcVaHOUboJFZA5Oh/6hQ6yV27resUymYxBQykRc10socv/NNjRm3KU31IX\nnvYosWCGdutkna1FtPxRz4fUZdezNMNnfELBdobQIpwwdGTkv/VIh0L7zmCu\nGdO7p55O3gcDbPsp66/eeTP/xpq2CkQh/j89oLcHAWLcM7UhrTns947roufB\nPAf+GTYlwW8ZaVgvaeuAFD9Z37HIMMPSVIo6X6Zyyva0EDgobKB04l+Aoi3M\nW1kiXgxCxWj6lHhK2BNYO4YpicRDDkT6TKp3uVaQVIm31UJ/0BO1745EqGeV\n39mjutd3jHYdDgdSGQApAkh7QGUe47Sxk9W0s7uMWxuuclAkaOVqdSxJP/X2\nvMZE\r\n=S+ii\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDEsJffpelsX+hm6zViyoLCTH1JoqdKJPIgmIQVmfrijQIgVqYG4NbtxC52oDhIeg84f1RksP8d5W2rghf3bc6Ea9s="}]},"maintainers":[{"email":"prplopes@gmail.com","name":"americas"},{"email":"cristiano.oliveira@uphold.com","name":"cristiano.oliveira"},{"email":"tiago.ribeiro@gmail.com","name":"fixe"},{"email":"comat8se@gmail.com","name":"franciscocardoso"},{"email":"me@kurayama.net","name":"kurayama"},{"email":"nunofgs@gmail.com","name":"nunofgs"},{"email":"pedrobrancolcc@gmail.com","name":"pedrobranco"},{"email":"mail@ricardolopes.net","name":"rplopes"},{"email":"ruipmarinho@gmail.com","name":"ruimarinho"}],"_npmUser":{"name":"nunofgs","email":"nunofgs@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-error-mapper_4.0.2_1588240865094_0.11321260933482846"},"_hasShrinkwrap":false},"4.1.0":{"name":"koa-error-mapper","version":"4.1.0","description":"An error mapper for Koa applications","keywords":["error","koa","mappers","mapping"],"homepage":"https://github.com/uphold/koa-error-mapper","bugs":{"url":"https://github.com/uphold/koa-error-mapper/issues"},"license":"MIT","contributors":[{"name":"Francisco Cardoso","email":"comat8se@gmail.com","url":"https://github.com/franciscocardoso"},{"name":"Miguel Martins","email":"me@kurayama.net","url":"https://github.com/kurayama"},{"name":"Nuno Sousa","email":"nunofgs@gmail.com","url":"https://github.com/nunofgs"},{"name":"Ricardo Lopes","email":"mail@ricardolopes.net","url":"https://github.com/rplopes"},{"name":"Tiago Ribeiro","email":"tiago.ribeiro@gmail.com","url":"https://github.com/fixe"}],"repository":{"type":"git","url":"git+https://github.com/uphold/koa-error-mapper.git"},"scripts":{"changelog":"uphold-scripts changelog v$npm_package_version","lint":"uphold-scripts lint","release":"uphold-scripts release","test":"uphold-scripts test","version":"uphold-scripts version"},"pre-commit":["lint"],"jest":{"collectCoverageFrom":["mappers/**/*.js"]},"devDependencies":{"http-errors":"^1.7.3","koa":"^2.11.0","supertest":"^4.0.2","uphold-scripts":"^0.4.0"},"engines":{"node":">= 7.6"},"gitHead":"ef6b014e01002df1f2323df9f98d901273db9b35","_id":"koa-error-mapper@4.1.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-BpX7vHL3Dwc/+lRsUFoxj5cNHuy9qbhVMkMoQw+xx0xXlXc7yyNY44somKyT9FLZfi5eheeIILaGP/7E1wUhVw==","shasum":"b2bee7e2a67e9c5ec5fc4d4f0a2e31b3ced26670","tarball":"https://registry.npmjs.org/koa-error-mapper/-/koa-error-mapper-4.1.0.tgz","fileCount":7,"unpackedSize":11205,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfpV9hCRA9TVsSAnZWagAAL3UQAIwy6WHgYykf88VUTsfO\nL/FJtI9VGPCUxriNG/oBGPQs9cBnYBSxy08BI86bfWSw0d96dHnVIrviekfA\nHZG5ot5Svv5mMfh9EJaMTgoWxz3cVgaKgGAjqD/uaNEj3+5umqfozf7dry0k\nHaZOkILbm4VaOViICNYpN/LfC40pvIAu1dF9WaS/chriVdzsEqZxuoiS5n2P\nuisdPnhUfw8+WIVGjgFyT4Mb2JtqxE46Y9rcHwR9bgL0IaQEKH0tYWw2HS9N\nU46llHps/qBhlEsaWm2LlL6ctQK8zAGuYBcxR2sIIKbpedXJvZYsz+VbGMLP\nXI6ZbnL9rTN89hUFnWYeO2kd06XzCo90XmAHL+DoP8yFeuoZII/F3lNJ4AHF\ne+o/vT0owdD1rpWb/NWQioBQ92Urs4/TajDP/dWTnc5cLB/OwietPmQhxVYh\nd2VOMV9ZhGGpAG71Q47i/H7C7/vquzDN7HoVxE01qm9LDuCCmJ8cxmQUBueR\nmSr5ohU5sqptztAEmXdEbxiA34/3Ypuae+yLO+lc1pzWbHD3HfFHsNc4NxNR\nZi9J4o6hL0s4z44AQr81xxJ6oX6oSrP6bf1p3itz7DgvdMVmBpxtFO7hnd5N\nY40Dfq6EKH3l3oeA8/46s/LBM1Z7heHHVqRHstZjMjzmYgctEDvxkM6gyv3v\nF/iv\r\n=5PIk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCxruSw/8vFEMzYDqhhS2Vt7ILvPcwJyfOMq5vSvw/7iQIhAMXWM6D+a67KQhdroeoAYh4jRBG8T+bd7iJ9xQEZZX/e"}]},"_npmUser":{"name":"nunofgs","email":"nunofgs@gmail.com"},"directories":{},"maintainers":[{"name":"ruimarinho","email":"ruipmarinho@gmail.com"},{"name":"rplopes","email":"mail@ricardolopes.net"},{"name":"cristiano.oliveira","email":"cristiano.oliveira@uphold.com"},{"name":"americas","email":"prplopes@gmail.com"},{"name":"kurayama","email":"me@kurayama.net"},{"name":"pedrobranco","email":"pedrobrancolcc@gmail.com"},{"name":"nunofgs","email":"nunofgs@gmail.com"},{"name":"fixe","email":"tiago.ribeiro@gmail.com"},{"name":"franciscocardoso","email":"comat8se@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-error-mapper_4.1.0_1604673377267_0.6965237818810015"},"_hasShrinkwrap":false}},"readme":"# koa-error-mapper\n\n`koa-error-mapper` is a middleware that handles application errors by mapping them to a custom format.\n\n## Status\n\n[![npm version][npm-image]][npm-url] [![build status][travis-image]][travis-url]\n\n## Installation\n\nInstall the package via `yarn`:\n\n```sh\n❯ yarn add koa-error-mapper\n```\n\nor via `npm`:\n\n```sh\n❯ npm install koa-error-mapper --save\n```\n\n## Usage\n\n### Mappers\n\nMappers are responsible for handling errors and normalizing the response. A generic fallback mapper is included in case no custom mapper is available.\n\nThe only interface for a mapper is a `map()` function. A mapper should return `undefined` if it is not capable or responsible for mapping a specific error. It must return an object with `status` and `body`. If not returned on the object, the value on the response will be `undefined` for precaution. It may also contain a `headers` property.\n\n```javascript\nmodule.exports = {\n  map(e) {\n    if (!(e instanceof CustomError)) {\n      return;\n    }\n\n    // Add your own custom logic here.\n    return { status: e.code, body: { message: e.message }, headers: { Foo: 'Bar' }};\n  }\n};\n```\n\nNow use the error mapper and register `CustomMapper`:\n\n```javascript\n'use strict';\n\nconst CustomError = require('path/to/my/custom/error');\nconst Koa = require('koa');\nconst app = new Koa();\nconst customMapper = require('path/to/my/custom/mapper');\n\napp.use(errorMapper([customMapper]);\n\napp.get('/', async () => {\n  throw new CustomError(401, 'Ah-ah!');\n});\n\napp.listen(3000);\n```\n\nResult:\n\n```sh\nGET /\n\nHTTP/1.1 401 Unauthorized\nFoo: Bar\n\n{ \"message\": \"Ah-ah!\" }\n```\n\n## Tests\n\n```sh\n❯ yarn test\n```\n\n## Release\n\n```sh\n❯ npm version [<new version> | major | minor | patch] -m \"Release %s\"\n```\n\n## License\n\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/koa-error-mapper.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/koa-error-mapper\n[travis-image]: https://img.shields.io/travis/uphold/koa-error-mapper.svg?style=flat-square\n[travis-url]: https://img.shields.io/travis/uphold/koa-error-mapper\n","maintainers":[{"email":"bot@uphold.com","name":"botatuphold"},{"email":"andremiguelcruz@msn.com","name":"satazor"},{"email":"prplopes@gmail.com","name":"americas"},{"email":"me@kurayama.net","name":"kurayama"},{"email":"pedrobrancolcc@gmail.com","name":"pedrobranco"},{"email":"tiago.ribeiro@gmail.com","name":"fixe"},{"email":"comat8se@gmail.com","name":"franciscocardoso"},{"email":"cristiano.oliveira@uphold.com","name":"cristiano.oliveira"},{"email":"ruipmarinho@gmail.com","name":"ruimarinho"}],"time":{"modified":"2023-10-27T14:49:50.968Z","created":"2017-03-22T19:01:29.012Z","4.0.1":"2017-03-22T19:01:29.012Z","4.0.2":"2020-04-30T10:01:05.204Z","4.1.0":"2020-11-06T14:36:17.369Z"},"homepage":"https://github.com/uphold/koa-error-mapper","keywords":["error","koa","mappers","mapping"],"repository":{"type":"git","url":"git+https://github.com/uphold/koa-error-mapper.git"},"contributors":[{"name":"Francisco Cardoso","email":"comat8se@gmail.com","url":"https://github.com/franciscocardoso"},{"name":"Miguel Martins","email":"me@kurayama.net","url":"https://github.com/kurayama"},{"name":"Nuno Sousa","email":"nunofgs@gmail.com","url":"https://github.com/nunofgs"},{"name":"Ricardo Lopes","email":"mail@ricardolopes.net","url":"https://github.com/rplopes"},{"name":"Tiago Ribeiro","email":"tiago.ribeiro@gmail.com","url":"https://github.com/fixe"}],"bugs":{"url":"https://github.com/uphold/koa-error-mapper/issues"},"license":"MIT","readmeFilename":"README.md","users":{"ricardogama":true}}