{"id":19138370,"url":"https://github.com/rickharrison/micro-json-error","last_synced_at":"2025-07-25T14:15:52.601Z","repository":{"id":57296434,"uuid":"70361582","full_name":"rickharrison/micro-json-error","owner":"rickharrison","description":"Outputs errors from your micro service in JSON.","archived":false,"fork":false,"pushed_at":"2016-10-09T00:23:58.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-04T03:52:09.774Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/rickharrison.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-08T22:51:31.000Z","updated_at":"2016-10-08T22:51:42.000Z","dependencies_parsed_at":"2022-09-07T03:20:55.840Z","dependency_job_id":null,"html_url":"https://github.com/rickharrison/micro-json-error","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickharrison%2Fmicro-json-error","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickharrison%2Fmicro-json-error/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickharrison%2Fmicro-json-error/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickharrison%2Fmicro-json-error/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rickharrison","download_url":"https://codeload.github.com/rickharrison/micro-json-error/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240221267,"owners_count":19767442,"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-11-09T06:42:45.497Z","updated_at":"2025-02-22T18:41:43.720Z","avatar_url":"https://github.com/rickharrison.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# micro-json-error\n\nWraps your [micro](https://github.com/zeit/micro) service function to catch errors and display them as JSON.\n\n### Installation\n\n```\nnpm install micro-json-error --save\n```\n\n### Usage\n\n```javascript\nconst { createError } = require('micro');\nconst jsonError = require('micro-json-error');\n\nmodule.exports = jsonError(async function (req, res) {\n  throw createError(400, 'Invalid data');\n});\n```\n\n### API\n\n```\njsonError(fn, { httpStatusCode = null, onError = null });\n```\n\n- `httpStatusCode` - Overrides the `statusCode` from the error for the http response status code. Useful if you always want to return a 200, and show the original `statusCode` in the JSON body.\n- `onError` - Callback function that will be passed the `error`. Useful for logging.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickharrison%2Fmicro-json-error","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickharrison%2Fmicro-json-error","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickharrison%2Fmicro-json-error/lists"}