{"id":20426522,"url":"https://github.com/futurestudio/hapi-response-utilities","last_synced_at":"2025-04-12T19:08:15.668Z","repository":{"id":32809924,"uuid":"142651483","full_name":"futurestudio/hapi-response-utilities","owner":"futurestudio","description":"hapi response decorations to conveniently compose responses","archived":false,"fork":false,"pushed_at":"2025-04-07T09:06:49.000Z","size":284,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T19:08:05.930Z","etag":null,"topics":["convenience","cookie","future-studio-university","hapi","hapi-decorations","hapi-plugin","hapijs","pdf"],"latest_commit_sha":null,"homepage":"","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/futurestudio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-07-28T06:00:25.000Z","updated_at":"2025-04-10T11:40:23.000Z","dependencies_parsed_at":"2023-01-16T22:45:11.265Z","dependency_job_id":"e86ca186-3962-4cf5-977b-6a6df51e3644","html_url":"https://github.com/futurestudio/hapi-response-utilities","commit_stats":{"total_commits":221,"total_committers":5,"mean_commits":44.2,"dds":0.5837104072398189,"last_synced_commit":"7469db8a655d13c6fa6ce8356f02143c3df424f2"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futurestudio%2Fhapi-response-utilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futurestudio%2Fhapi-response-utilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futurestudio%2Fhapi-response-utilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futurestudio%2Fhapi-response-utilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/futurestudio","download_url":"https://codeload.github.com/futurestudio/hapi-response-utilities/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618276,"owners_count":21134200,"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":["convenience","cookie","future-studio-university","hapi","hapi-decorations","hapi-plugin","hapijs","pdf"],"created_at":"2024-11-15T07:16:49.840Z","updated_at":"2025-04-12T19:08:15.628Z","avatar_url":"https://github.com/futurestudio.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"471\" style=\"max-width:100%;\" src=\"https://github.com/futurestudio/hapi-response-utilities/blob/master/media/hapi-response-utilities.png?raw=true\" alt=\"hapi-response-utilities logo\"\u003e\n  \u003cbr/\u003e\n  \u003cbr/\u003e\n  \u003cp\u003e\n    hapi response decorations to conveniently compose responses\n  \u003c/p\u003e\n  \u003cbr/\u003e\n  \u003cp\u003e\n    \u003ca href=\"#installation\"\u003e\u003cstrong\u003eInstallation\u003c/strong\u003e\u003c/a\u003e ·\n    \u003ca href=\"#usage\"\u003e\u003cstrong\u003eUsage\u003c/strong\u003e\u003c/a\u003e ·\n    \u003ca href=\"#methods\"\u003e\u003cstrong\u003eMethods\u003c/strong\u003e\u003c/a\u003e\n  \u003c/p\u003e\n  \u003cbr/\u003e\n  \u003cbr/\u003e\n  \u003cp\u003e\n\n[![Build Status](https://travis-ci.org/futurestudio/hapi-response-utilities.svg?branch=master)](https://travis-ci.org/futurestudio/hapi-response-utilities)\n  \u003ca href=\"https://snyk.io/test/github/futurestudio/hapi-response-utilities\"\u003e\u003cimg src=\"https://snyk.io/test/github/futurestudio/hapi-response-utilities/badge.svg\" alt=\"Known Vulnerabilities\" data-canonical-src=\"https://snyk.io/test/github/futurestudio/hapi-response-utilities\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/hapi-response-utilities\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/hapi-response-utilities.svg\" alt=\"hapi-response-utilities Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/hapi-response-utilities\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/hapi-response-utilities.svg\" alt=\"Monthly downloads\"\u003e\u003c/a\u003e\n  \u003c/p\u003e\n  \u003cp\u003e\n    \u003cem\u003eFollow \u003ca href=\"http://twitter.com/marcuspoehls\"\u003e@marcuspoehls\u003c/a\u003e for updates!\u003c/em\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n------\n\n\u003cp align=\"center\"\u003e\u003csup\u003eDevelopment of this hapi plugin is supported by \u003ca href=\"https://futurestud.io\"\u003eFuture Studio University 🚀\u003c/a\u003e\u003c/sup\u003e\n\u003cbr\u003e\u003cb\u003e\nJoin the \u003ca href=\"https://futurestud.io/university\"\u003eFuture Studio University and Skyrocket in Node.js\u003c/a\u003e\u003c/b\u003e\n\u003c/p\u003e\n\n------\n\n\n## Introduction\nA hapi plugin that decorates the response toolkit `h` with methods to conveniently compose responses.\n\n\n## Requirements\n\u003e **hapi v19 (or later)** and **Node.js v12 (or newer)**\n\nThis plugin requires **hapi v19** (or later) and **Node.js v12 or newer**.\n\n\n### Compatibility\n| Major Release | [hapi.js](https://github.com/hapijs/hapi) version | Node.js version |\n| --- | --- | --- |\n| `v2` | `\u003e=17 hapi` | `\u003e=12` |\n| `v1` | `\u003e=17 hapi` | `\u003e=8` |\n\n\n## Installation\nAdd `hapi-response-utilities` as a dependency to your project:\n\n```bash\nnpm i hapi-response-utilities\n```\n\n\n## Usage\nRegister `hapi-response-utilities` to your hapi server and that's it :)\n\n```js\nawait server.register({\n  plugin: require('hapi-response-utilities')\n})\n\n// went smooth like hot chocolate :)\n```\n\n\n## Methods\nAn overview of available hapi `toolkit` decorations.\n\n\n#### h.pdf(pdf-content, filename)\nCreates a PDF response including the PDF related content type and HTTP headers allowing a custom filename.\n\nThe `filename` defaults to `download`.\n\n```js\nhandler: async (_, h) =\u003e {\n  const content = await createPdfContent()\n  return h.pdf(content, 'filename.pdf')\n}\n```\n\n\n#### h.status(code)\nShortcut to respond with just an HTTP status code.\n\n```js\nhandler: (_, h) =\u003e {\n  return h.status(204)\n}\n```\n\n\n#### h.cookie(key, value, options)\nSets a cookie for the given key-value-pair. It's a convenience method for `h.state`.\n\n```js\nhandler: (_, h) =\u003e {\n  return\n    h.cookie('userId', '1')\n     .cookie('username', 'Marcus')\n     .continue\n}\n```\n\n\n#### h.header(key, value, options)\nSet a response header for the given key-value-pair. This method provides a unified interface to set response headers, no matter if the response is a hapi response object or a boom error instance:\n\n```js\nhandler: (_, h) =\u003e {\n  return h\n    .header('content-type', 'text/html')\n    .header('api-key', 'secret-api-key')\n    .continue\n}\n```\n\nThe accepted [`options`](https://hapi.dev/api/?v=18.4.0#-responseheadername-value-options) are the same as provided by hapi itself.\n\n\n#### h.headers()\nReturns an object containing the response headers. This method provides a unified interface to set response headers, no matter if the response is a hapi response object or a boom error instance:\n\n```js\nhandler: (_, h) =\u003e {\n  const responseHeaders = h.headers()\n\n  return h.continue\n}\n```\n\n\n#### h.isView()\nDetermines whether the response is a rendered view:\n\n```js\nhandler: (_, h) =\u003e {\n  if (h.isView()) {\n    // handle view response\n  }\n\n  return h.continue\n}\n```\n\n\n## Feature Requests\nDo you miss a feature? Please don’t hesitate to\n[create an issue](https://github.com/futurestudio/hapi-response-utilities/issues) with a short description of your desired addition to this plugin.\n\n\n## Links \u0026 Resources\n\n- [hapi tutorial series](https://futurestud.io/tutorials/hapi-get-your-server-up-and-running) with 100+ tutorials\n\n\n## Contributing\n\n1.  Create a fork\n2.  Create your feature branch: `git checkout -b my-feature`\n3.  Commit your changes: `git commit -am 'Add some feature'`\n4.  Push to the branch: `git push origin my-new-feature`\n5.  Submit a pull request 🚀\n\n\n## License\n\nMIT © [Future Studio](https://futurestud.io)\n\n---\n\n\u003e [futurestud.io](https://futurestud.io) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e GitHub [@futurestudio](https://github.com/futurestudio/) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e Twitter [@futurestud_io](https://twitter.com/futurestud_io)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturestudio%2Fhapi-response-utilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuturestudio%2Fhapi-response-utilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturestudio%2Fhapi-response-utilities/lists"}