{"id":14676791,"url":"https://github.com/hmil/express-youch","last_synced_at":"2025-07-12T16:09:00.700Z","repository":{"id":32809327,"uuid":"142894697","full_name":"hmil/express-youch","owner":"hmil","description":"Awesome error reporting middleware for express","archived":false,"fork":false,"pushed_at":"2023-01-23T20:55:02.000Z","size":341,"stargazers_count":10,"open_issues_count":11,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-19T12:24:57.828Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hmil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-30T15:32:09.000Z","updated_at":"2023-08-01T11:21:55.000Z","dependencies_parsed_at":"2023-02-13T03:05:42.794Z","dependency_job_id":null,"html_url":"https://github.com/hmil/express-youch","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmil%2Fexpress-youch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmil%2Fexpress-youch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmil%2Fexpress-youch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmil%2Fexpress-youch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmil","download_url":"https://codeload.github.com/hmil/express-youch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":218774512,"owners_count":16385593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-12T09:00:55.972Z","updated_at":"2024-09-12T09:02:35.641Z","avatar_url":"https://github.com/hmil.png","language":"TypeScript","funding_links":[],"categories":["Middleware"],"sub_categories":[],"readme":"# Beautiful error reporting for express\n\n[![Build Status](https://travis-ci.org/hmil/express-youch.svg?branch=master)](https://travis-ci.org/hmil/express-youch)\n\nBeautiful, spec-compliant error reporting for express.\n\n## What does this do?\n\nThis express middleware simplifies debugging errors in express applications by presenting errors in a developer-friendly way.\n\nFeatures:\n- Beautiful HTML error reports thanks to [youch](https://github.com/poppinss/youch)\n- Respects the `Accept` HTTP header\n- Hides sensitive information when running in production\n- Compatible with other error middleware (custom error pages, custom error logging, ...)\n\n## Usage\n\n```\nnpm install express-youch\n```\n\n```js\nconst { errorReporter } = require('express-youch');\n\napp.use(errorReporter());\n```\n\n## Configuration options\n\n### links\n\nAdd custom links to the error report.\n\n```ts\napp.use(errorReporter({\n    links: [\n        ({message}) =\u003e{\n            const url = `https://stackoverflow.com/search?q=${encodeURIComponent(`[adonis.js] ${message}`)}`;\n            return `\u003ca href=\"${url}\" target=\"_blank\" title=\"Search on stackoverflow\"\u003eSearch stackoverflow\u003c/a\u003e`;\n        }\n    ]\n}));\n```\n\n## Recepies\n\n### How do I customize the error pages?\n\nWhen running in production (_ie. when the `NODE_ENV` environment variable is set to `production`._), `express-youch` will delegate HTML errors to the next error reporting middleware. Here is a basic example:\n\n```js\nconst { errorReporter } = require('express-youch');\n\n// First, pass the errors to the error reporter\napp.use(errorReporter());\n\n// Then add some custom handling logic\napp.use(function (error, req, res, next) {\n    if (!res.headersSent) {\n        // If we get to this point, that means express-youch decided to delegate response rendering to the \n        // next handler in the chain. You can safely assume the client wants an HTML response here.\n        res .status(error.statusCode)\n            .render('error-page', { error });\n    } else {\n        next(error);\n    }\n});\n```\n\nThe error object contains the properties `statusCode` and `message`, which you may use to create different error pages for different error types.\n\n### How to better manage my errors\n\nYou should us a combination of an asynchronous express router such as [this one](https://www.npmjs.com/package/express-async-router) and the **async/await** syntax to make sure no errors leak outside of your control. Read [this blog post](https://www.npmjs.com/package/express-async-router) to learn more about error handling in express.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmil%2Fexpress-youch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmil%2Fexpress-youch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmil%2Fexpress-youch/lists"}