{"name":"@eggjs/onerror","version":"3.0.0","keywords":["egg","egg-plugin","onerror"],"author":{"name":"dead_horse"},"_id":"@eggjs/onerror@3.0.0","maintainers":[{"name":"gxkl","email":"gxkl203@gmail.com"},{"name":"eggjs-admin","email":"fengmk2+eggjs@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"atian25","email":"atian25@qq.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"wanghx","email":"whxaxes@gmail.com"},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"mansonchor.zzw","email":"mansonchor1987@gmail.com"},{"name":"hubcarl","email":"hubcarl@126.com"},{"name":"gemwuu","email":"gemwuu@gmail.com"},{"name":"akitasummer","email":"644171127@qq.com"}],"homepage":"https://github.com/eggjs/onerror#readme","bugs":{"url":"https://github.com/eggjs/onerror/issues"},"dist":{"shasum":"dd3feaf51b4d36305b3598cac24d69c364d5673c","tarball":"http://registry-npm.ywwl.com/@eggjs/onerror/download/@eggjs/onerror-3.0.0.tgz","fileCount":45,"integrity":"sha512-7lXj7vYqZDQTvGX5Kva7NZiMnCJQZZK4LbEl8nwL5ymbwWptCBQq1o/dxmulCa+uc7n5Omj5MLZxIh9jzi9iUA==","signatures":[{"sig":"MEQCIGLz0w5YsVlz9X058Lgx6CU2YkhrNRMWdGOBSXEgB8THAiBjBBTamXRq4ftGxBw47oG9RqQOzfLsioCgbD7eGMmBrQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2fonerror@3.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":202093,"size":47803,"noattachment":false,"key":"/@eggjs/onerror/-/@eggjs/onerror-3.0.0.tgz"},"main":"./dist/commonjs/index.js","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">= 18.19.0"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"9de0ff59b2efa6fda267364fd6ed83672903d11c","scripts":{"ci":"egg-bin cov","lint":"eslint --cache src test --ext .ts","test":"egg-bin test","clean":"rimraf dist","preci":"npm run clean &&  npm run lint","postci":"npm run prepublishOnly && npm run clean","pretest":"npm run clean && npm run lint -- --fix","prepublishOnly":"tshy && tshy-after && attw --pack"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"eggPlugin":{"name":"onerror","exports":{"import":"./dist/esm","require":"./dist/commonjs","typescript":"./src"},"optionalDependencies":["jsonp"]},"repository":{"url":"git+https://github.com/eggjs/onerror.git","type":"git"},"_npmVersion":"10.8.2","description":"error handler for egg","directories":{},"_nodeVersion":"20.18.2","dependencies":{"cookie":"^1.0.2","mustache":"^4.2.0","@eggjs/core":"^6.3.1","koa-onerror":"^5.0.1","stack-trace":"^0.0.10"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^4.0.4","tshy":"3","eslint":"8","rimraf":"6","@eggjs/bin":"7","tshy-after":"1","typescript":"5","@eggjs/mock":"^6.0.5","@types/node":"22","@types/mocha":"10","@eggjs/tsconfig":"1","@types/mustache":"^4.2.5","eslint-config-egg":"14","@types/stack-trace":"^0.0.33","@arethetypeswrong/cli":"^0.17.3"},"_npmOperationalInternal":{"tmp":"tmp/onerror_3.0.0_1738511505702_0.44149699886579175","host":"s3://npm-registry-packages-npm-production"},"readme":"# @eggjs/onerror\n\n[![NPM version][npm-image]][npm-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n[![Node.js Version](https://img.shields.io/node/v/@eggjs/onerror.svg?style=flat)](https://nodejs.org/en/download/)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)\n![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/eggjs/onerror)\n\n[npm-image]: https://img.shields.io/npm/v/@eggjs/onerror.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@eggjs/onerror\n[snyk-image]: https://snyk.io/test/npm/@eggjs/onerror/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/@eggjs/onerror\n[download-image]: https://img.shields.io/npm/dm/@eggjs/onerror.svg?style=flat-square\n[download-url]: https://npmjs.org/package/@eggjs/onerror\n\nDefault error handling plugin for egg.\n\n## Usage\n\n`onerror` plugin is enabled by default in egg. But you still can configure its properties to fits your scenarios.\n\n- `errorPageUrl: String or Function` - If user request html pages in production environment and unexpected error happened, it will redirect user to `errorPageUrl`.\n- `accepts: Function` - detect user's request accept `json` or `html`.\n- `all: Function` - customize error handler, if `all` present, negotiation will be ignored.\n- `html: Function` - customize html error handler.\n- `text: Function` - customize text error handler.\n- `json: Function` - customize json error handler.\n- `js: Function` - customize JSONP error handler.\n\n```ts\n// config/config.default.ts\nimport { defineConfig } from 'egg';\n\nexport default defineConfig({\n  onerror: {\n    // errorPageUrl support function\n    errorPageUrl: (err, ctx) => ctx.errorPageUrl || '/500',\n  },\n});\n\n// an accept detect function that mark all request with `x-requested-with=XMLHttpRequest` header accepts json.\nfunction accepts(ctx) {\n  if (ctx.get('x-requested-with') === 'XMLHttpRequest') return 'json';\n  return 'html';\n}\n```\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/eggjs/egg/issues).\n\n## License\n\n[MIT](LICENSE)\n\n## Contributors\n\n[![Contributors](https://contrib.rocks/image?repo=eggjs/egg)](https://github.com/eggjs/egg/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n","publish_time":1738511505950,"_cnpm_publish_time":1738511505950,"dist-tags":{"beta":"4.0.2-beta.27","latest":"4.1.0","rc":"4.0.2-rc.1"}}