{"id":17190386,"url":"https://github.com/theworkflow/json-api-errors","last_synced_at":"2025-03-25T05:53:30.329Z","repository":{"id":57284647,"uuid":"67562646","full_name":"theworkflow/json-api-errors","owner":"theworkflow","description":"JSON API Errors formatter","archived":false,"fork":false,"pushed_at":"2016-09-12T00:51:24.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T00:01:32.901Z","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/theworkflow.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":"2016-09-07T02:01:05.000Z","updated_at":"2016-09-07T02:05:33.000Z","dependencies_parsed_at":"2022-09-17T02:14:44.012Z","dependency_job_id":null,"html_url":"https://github.com/theworkflow/json-api-errors","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theworkflow%2Fjson-api-errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theworkflow%2Fjson-api-errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theworkflow%2Fjson-api-errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theworkflow%2Fjson-api-errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theworkflow","download_url":"https://codeload.github.com/theworkflow/json-api-errors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245407763,"owners_count":20610232,"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-10-15T01:22:25.103Z","updated_at":"2025-03-25T05:53:30.300Z","avatar_url":"https://github.com/theworkflow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON API Errors\n\nCreate errors using [JSON API errors format](http://jsonapi.org/format/#errors)\n\n[![npm package](https://nodei.co/npm/json-api-errors.png?downloads=true\u0026downloadRank=true\u0026stars=true)][package]\n\n\n[![version](https://img.shields.io/npm/v/json-api-errors.svg?style=flat-square)][version]\n[![build](https://img.shields.io/travis/theworkflow/json-api-errors/master.svg?style=flat-square)][build]\n[![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]\n[![climate](https://img.shields.io/codeclimate/github/theworkflow/json-api-errors.svg?style=flat-square)][climate]\n[![coverage](https://img.shields.io/codeclimate/coverage/github/theworkflow/json-api-errors.svg?style=flat-square)][coverage]\n\n### Installation\n\n`$ npm install json-api-errors`\n\n### Usage\n\n#### `Errors.createSingle(id, message, [meta])`\n\nCreate a single errors object.\n\n- `id` (String)\n - required\n- `message` (String)\n - required\n- `meta` (Object | String)\n - optional\n\n```javascript\nconst Errors = require('json-api-errors')\n\nvar errors = new Errors()\nvar err = errors.createSingle('CUSTOM_ERROR', 'Custom error message')\n\nconsole.log(err)\n// {\n//   errors: [{ id: 'CUSTOM_ERROR', message: 'Custom error message' }]\n// }\n```\n\n#### `Errors.add(id, message, [meta])`\n\nAdd an error to the errors array\n\n- `id` (String)\n - required\n- `message` (String)\n - required\n- `meta` (Object | String)\n - optional\n\n```javascript\nconst Errors = require('json-api-errors')\n\nvar errors = new Errors()\nerrors.add('CUSTOM_ERROR', 'Custom error message')\n```\n\n#### `Errors.get()`\n\nRetreive all errors. Errors are returned in a JSON format\n\n```javascript\nconst Errors = require('json-api-errors')\n\nvar errors = new Errors()\nerrors.add('CUSTOM_ERROR', 'Custom error message')\n\nvar errs = errors.get()\n// {\n//   errors: [{ id: 'CUSTOM_ERROR', message: 'Custom error message' }]\n// }\n```\n\n#### `Errors.clear()`\n\nRemove all errors\n\n```javascript\nconst Errors = require('json-api-errors')\n\nvar errList, errors = new Errors()\n\nerrors.add('CUSTOM_ERROR', 'Custom error message')\n\nerrList = errors.get()\nconsole.log(errList.errors) // Length is 1\n\nerrors.clear()\nerrList = errors.get()\n\nconsole.log(errList.errors) // Length is 0\n```\n\n### Tests\n\n`$ npm test`\n\n[package]: https://nodei.co/npm/json-api-errors\n[version]: https://www.npmjs.com/package/json-api-errors\n[build]: https://travis-ci.org/theworkflow/api-util\n[license]: https://raw.githubusercontent.com/theworkflow/json-api-errors/master/LICENSE\n[climate]: https://codeclimate.com/github/theworkflow/json-api-errors\n[coverage]: https://codeclimate.com/github/theworkflow/json-api-errors/coverage","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheworkflow%2Fjson-api-errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheworkflow%2Fjson-api-errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheworkflow%2Fjson-api-errors/lists"}