{"id":20426507,"url":"https://github.com/futurestudio/hapi-class-extension-points","last_synced_at":"2025-04-12T19:08:12.597Z","repository":{"id":34933000,"uuid":"190743060","full_name":"futurestudio/hapi-class-extension-points","owner":"futurestudio","description":"hapi plugin that registers lifecycle extension points from class methods","archived":false,"fork":false,"pushed_at":"2024-01-26T04:09:41.000Z","size":221,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T13:21:15.476Z","etag":null,"topics":[],"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":"2019-06-07T12:53:11.000Z","updated_at":"2022-11-08T12:16:05.000Z","dependencies_parsed_at":"2023-01-16T23:01:00.585Z","dependency_job_id":"6b4c6d34-4054-4c1e-b38f-d008deb76f7d","html_url":"https://github.com/futurestudio/hapi-class-extension-points","commit_stats":{"total_commits":181,"total_committers":6,"mean_commits":"30.166666666666668","dds":0.6685082872928176,"last_synced_commit":"a40a7ed895318f663314ee86c8934746a982c50a"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futurestudio%2Fhapi-class-extension-points","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futurestudio%2Fhapi-class-extension-points/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futurestudio%2Fhapi-class-extension-points/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futurestudio%2Fhapi-class-extension-points/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/futurestudio","download_url":"https://codeload.github.com/futurestudio/hapi-class-extension-points/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317701,"owners_count":21083528,"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-15T07:16:46.281Z","updated_at":"2025-04-12T19:08:12.573Z","avatar_url":"https://github.com/futurestudio.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg width=\"471\" style=\"max-width:100%;\" src=\"https://raw.githubusercontent.com/futurestudio/hapi-class-extension-points/master/media/hapi-class-extension-points.png\" alt=\"hapi-class-extension-points logo\"\u003e\n  \u003cbr/\u003e\n  \u003cbr/\u003e\n  \u003cp\u003e\n    Use class methods to add lifecycle extension points to your hapi server.\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=\"#contributing\"\u003e\u003cstrong\u003eContribute\u003c/strong\u003e\u003c/a\u003e\n  \u003c/p\u003e\n  \u003cbr/\u003e\n  \u003cbr/\u003e\n  \u003cp\u003e\n    \u003ca href=\"https://travis-ci.com/futurestudio/hapi-class-extension-points\"\u003e\u003cimg src=\"https://travis-ci.com/futurestudio/hapi-class-extension-points.svg?branch=master\" alt=\"Build Status\" data-canonical-src=\"https://travis-ci.com/futurestudio/hapi-class-extension-points.svg?branch=master\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://snyk.io/test/github/futurestudio/hapi-class-extension-points\"\u003e\u003cimg src=\"https://snyk.io/test/github/futurestudio/hapi-class-extension-points/badge.svg\" alt=\"Known Vulnerabilities\" data-canonical-src=\"https://snyk.io/test/github/futurestudio/hapi-class-extension-points\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/hapi-class-extension-points\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/hapi-class-extension-points.svg\" alt=\"hapi-class-extension-points Version\" data-canonical-src=\"https://img.shields.io/npm/v/hapi-class-extension-points.svg\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n        \u003ca href=\"https://www.npmjs.com/package/hapi-class-extension-points\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/hapi-class-extension-points.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\u003eThe \u003ca href=\"https://futurestud.io\"\u003eFuture Studio University\u003c/a\u003e supports development of this hapi plugin 🚀\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\nThis hapi plugin adds the `server.extClass(class)` decoration to register lifecycle extensions from class methods.\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-class-extension-points` as a dependency to your project:\n\n```bash\nnpm i hapi-class-extension-points\n```\n\n\n## Usage\nRegister `hapi-class-extension-points` to your hapi server. This will decorate the hapi `server` with a `server.extClass()` method:\n\n```js\nawait server.register({\n  plugin: require('hapi-class-extension-points')\n})\n\n// went smooth like chocolate :)\n// now your hapi server supports 'server.extClass(class MyMiddleware {})'\n```\n\nHaving the plugin registered, you can now write your lifecycle extension points as classes:\n\n```js\nclass RateLimiting {\n  constructor (server) {\n    this.server = server\n  }\n\n  async onRequest (request, h) {\n    // rate limit the request\n\n    await this.handle(request)\n\n    return h.continue\n  }\n\n  async handle (request) {\n    // this is a private method that won't be registered as a lifecycle extension\n  }\n\n  onPreResponse (request, h) {\n    // add rate limiting headers\n\n    return h.continue\n  }\n}\n\nserver.extClass(RateLimiting)\n```\n\nThat's it! The constructor of your class receives the hapi server. You can then store it as a class property and use it when needed!\n\nEnjoy!\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-class-extension-points","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuturestudio%2Fhapi-class-extension-points","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturestudio%2Fhapi-class-extension-points/lists"}