{"id":24087118,"url":"https://github.com/hapipal/avocat","last_synced_at":"2025-05-05T17:54:43.488Z","repository":{"id":41040734,"uuid":"127412919","full_name":"hapipal/avocat","owner":"hapipal","description":"A simple library to convert objection errors to boom errors","archived":false,"fork":false,"pushed_at":"2023-04-05T18:00:20.000Z","size":30,"stargazers_count":8,"open_issues_count":2,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-01T04:36:01.885Z","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/hapipal.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-30T10:02:16.000Z","updated_at":"2023-02-14T09:52:25.000Z","dependencies_parsed_at":"2024-06-19T09:53:52.442Z","dependency_job_id":"eb6f82af-e3d3-4c37-b627-433583485e47","html_url":"https://github.com/hapipal/avocat","commit_stats":{"total_commits":26,"total_committers":6,"mean_commits":4.333333333333333,"dds":0.6923076923076923,"last_synced_commit":"dbb7b709624d17f8b91068e5404e1192a1305f78"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Favocat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Favocat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Favocat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Favocat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hapipal","download_url":"https://codeload.github.com/hapipal/avocat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252546473,"owners_count":21765778,"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":"2025-01-10T03:02:09.964Z","updated_at":"2025-05-05T17:54:43.482Z","avatar_url":"https://github.com/hapipal.png","language":"JavaScript","readme":"# avocat\n\nA utility to convert [Objection](https://vincit.github.io/objection.js/) database errors into [Boom](https://hapi.dev/module/boom/) HTTP errors\n\n[![Build Status](https://travis-ci.com/hapipal/avocat.svg?branch=master)](https://travis-ci.com/hapipal/avocat) [![Coverage Status](https://coveralls.io/repos/github/hapipal/avocat/badge.svg?branch=master)](https://coveralls.io/github/hapipal/avocat?branch=master)\n\nLead Maintainer: [Daniel Cole](https://github.com/optii)\n\n## Installation\n```sh\nnpm install @hapipal/avocat\n```\n\n## Usage\n\u003e See also the [API Reference](API.md)\n\u003e\n\u003e Avocat is intended for use with hapi v19+, nodejs v12+, and Objection v2 or v3 (_see v1 for lower support_).\n\nAvocat provides a single utility function [`Avocat.rethrow(error, [options])`](API.md#avocatrethrowerror-options) which transforms database errors from Objection into Boom HTTP errors that are compatible with hapi.\n\n```js\n'use strict';\n\nconst Hapi = require('@hapi/hapi');\nconst Avocat = require('@hapipal/avocat');\nconst User = require('./user-model'); // An Objection model bound to a knex instance\n\nconst server = Hapi.server();\n\nserver.route({\n    method: 'get',\n    path: '/users/{id}',\n    handler(request) {\n\n        try {\n            return await User.query()\n                .findById(request.params.id)\n                .throwIfNotFound();\n        }\n        catch (err) {\n            Avocat.rethrow(err); // Throws a 404 Not Found if user does not exist\n            throw err;\n        }\n    }\n});\n```\n\n## Extras\nThe interface for Avocat is heavily inspired by [Bounce](https://hapi.dev/module/bounce/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapipal%2Favocat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhapipal%2Favocat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapipal%2Favocat/lists"}