{"id":13475788,"url":"https://github.com/hapipal/underdog","last_synced_at":"2025-05-05T17:55:28.926Z","repository":{"id":55205305,"uuid":"66811348","full_name":"hapipal/underdog","owner":"hapipal","description":"HTTP/2 server-push for hapi","archived":false,"fork":false,"pushed_at":"2021-04-12T03:48:47.000Z","size":65,"stargazers_count":60,"open_issues_count":0,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-09-14T13:09:58.533Z","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}},"created_at":"2016-08-29T04:29:23.000Z","updated_at":"2023-11-03T17:12:30.000Z","dependencies_parsed_at":"2022-08-14T16:02:57.500Z","dependency_job_id":null,"html_url":"https://github.com/hapipal/underdog","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Funderdog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Funderdog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Funderdog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Funderdog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hapipal","download_url":"https://codeload.github.com/hapipal/underdog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222182592,"owners_count":16944870,"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-07-31T16:01:23.597Z","updated_at":"2024-10-30T07:31:23.230Z","avatar_url":"https://github.com/hapipal.png","language":"JavaScript","readme":"# underdog\nHTTP/2 server-push for hapi\n\n[![Build Status](https://travis-ci.com/hapipal/underdog.svg?branch=master)](https://travis-ci.com/hapipal/underdog) [![Coverage Status](https://coveralls.io/repos/hapipal/underdog/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/hapipal/underdog?branch=master)\n\nLead Maintainer - [Devin Ivy](https://github.com/devinivy)\n\n## Installation\n```sh\nnpm install underdog\n```\n\n## Usage\n\u003e See also the [API Reference](API.md)\n\u003e\n\u003e Underdog is intended for use with hapi v19+ and nodejs v12+ (see v4 for lower support).\n\u003e\n\u003e This module is currently under [ad hoc maintenance](https://github.com/hapipal/underdog/issues/17), which means it relies fully on community support.\n\nUnderdog brings [HTTP/2 server-push](http://httpwg.org/specs/rfc7540.html#PushResources) to hapi.  The way it works is that you specify paths to resources that you'd like to push alongside a particular response.  This is achieved with a call to the response toolkit decoration [`h.push()`](API.md#hpushresponse-path-headers).  Before hapi responds to the original request, those push-requests will be made internally and their results will be streamed to the client as push-responses.  Even pushed resources can specify additional resources to push.  You can't make this stuff up!\n\n### Example\n```js\nconst Fs = require('fs');\nconst Http2 = require('http2');\nconst Hapi = require('@hapi/hapi');\nconst Underdog = require('underdog');\n\n(async () =\u003e {\n\n    const listener = Http2.createSecureServer({\n        // See tests for a key/cert that you can use to try this out\n        key: Fs.readFileSync(`${__dirname}/localhost.key`),\n        cert: Fs.readFileSync(`${__dirname}/localhost.cert`)\n    });\n\n    const server = Hapi.server({\n        listener,\n        tls: true,\n        port: 3000\n    });\n\n    await server.register(Underdog);\n\n    server.route([\n        {\n            method: 'get',\n            path: '/',\n            handler: (request, h) =\u003e {\n\n                const response = h.response('\u003cscript src=\"/push-me.js\"\u003e\u003c/script\u003e');\n\n                h.push(response, 'push-me.js');\n\n                return response;\n            }\n        },\n        {\n            method: 'get',\n            path: '/push-me.js',\n            handler: (request) =\u003e {\n\n                return 'document.write(\\'I was definitely pushed!\\');';\n            },\n            // To demonstrate that it must have been pushed, not requested directly\n            config: { isInternal: true }\n        }\n    ]);\n\n    await server.start();\n\n    console.log(`Check-out ${server.info.uri} in your favorite HTTP/2-supporting client`);\n})();\n```\n\n### Compatibility\nUnderdog is compatible with nodejs's [`Http2Server`](https://nodejs.org/api/http2.html#http2_http2_createserver_options_onrequesthandler) and [`Http2SecureServer`](https://nodejs.org/api/http2.html#http2_http2_createsecureserver_options_onrequesthandler) under the [Compatibility API](https://nodejs.org/api/http2.html#http2_compatibility_api).  Using any other HTTP server will simply disable server-push; [`h.push()`](API.md#hpushresponse-path-headers) will no-op and return `{ response, allowed: false }` and [`h.pushAllowed()`](API.md#hpushallowed) will return `false`.\n\n## Extras\n - The HTTP/2 spec ([here](http://httpwg.org/specs/rfc7540.html))\n - For debugging HTTP/2 in Chrome, see `chrome://net-internals/#http2`\n - Nodejs's HTTP/2 docs ([here](https://nodejs.org/api/http2.html))\n - Shout-out to the original userland [spdy](https://github.com/indutny/node-spdy) and  [http2](https://github.com/molnarg/node-http2) modules.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapipal%2Funderdog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhapipal%2Funderdog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapipal%2Funderdog/lists"}