{"id":21107747,"url":"https://github.com/stealjs/steal-push","last_synced_at":"2025-07-25T20:11:50.800Z","repository":{"id":57370495,"uuid":"97843970","full_name":"stealjs/steal-push","owner":"stealjs","description":"HTTP/2 for StealJS projects","archived":false,"fork":false,"pushed_at":"2019-06-19T19:33:59.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-08T20:15:58.454Z","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/stealjs.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-20T14:18:46.000Z","updated_at":"2019-06-19T19:33:57.000Z","dependencies_parsed_at":"2022-08-29T19:00:23.022Z","dependency_job_id":null,"html_url":"https://github.com/stealjs/steal-push","commit_stats":null,"previous_names":["matthewp/steal-push"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stealjs%2Fsteal-push","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stealjs%2Fsteal-push/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stealjs%2Fsteal-push/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stealjs%2Fsteal-push/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stealjs","download_url":"https://codeload.github.com/stealjs/steal-push/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243230091,"owners_count":20257642,"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-20T00:42:15.632Z","updated_at":"2025-03-14T09:23:20.797Z","avatar_url":"https://github.com/stealjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# steal-push\n\n[![Build Status](https://travis-ci.org/stealjs/steal-push.svg?branch=master)](https://travis-ci.org/stealjs/steal-push)\n[![npm version](https://badge.fury.io/js/steal-push.svg)](http://badge.fury.io/js/steal-push)\n\n**steal-push** is server middleware for HTTP2 push. Using steal-tools you can create a **bundle manifest** that species which modules need to be loaded for each *bundle*. steal-push uses this manifest file to push files when a given route is used.\n\nsteal-push also works with HTTP1 servers, adding a [Link header](https://w3c.github.io/preload/#server-push-(http/2)) which tells the browser to begin fetching/parsing the assets.\n\n## Install\n\n```\nnpm install steal-push --save\n```\n\n## Setup\n\nBefore using steal-push you must generate a [bundle manifest](https://stealjs.com/docs/steal-tools.BuildOptions.html) from steal-tools like so:\n\n```js\nstealTools.build(config, {\n\tbundleManifest: true\n});\n```\n\n## Usage\n\nsteal-push can be used in plain Node web servers, or in express apps.\n\n### Node\n\n```js\nconst http2 = require(\"spdy\");\nconst stealPush = require(\"steal-push\");\n\nconst pushMain = stealPush(\"main\");\nconst pushOrders = stealPush(\"orders\");\n\n\nfunction app(req, res) {\n  if(req.url === \"/\") {\n    pushMain(req, res);\n    res.send(\"\u003cbody\u003eHello world!\u003c/body\u003e\");\n  } else {\n    pushOrders(req, res);\n    res.send(\"\u003cbody\u003e\u003ch1\u003eOrders\u003c/h1\u003e ... \u003c/body\u003e\");\n  }\n}\n\n\nspdy.createServer({\n  key: fs.readFileSync(\"path/to/key.pem\"),\n  cert: fs.readFileSync(\"path/to/cert.pem\"),\n  spdy: {\n    protocols: [\"h2\", \"http/1.1\"]\n  }\n}, app).listen(8080);\n\n```\n\n### Express\n\n```js\nconst express = require(\"express\");\nconst fs = require(\"fs\");\nconst stealPush = require(\"steal-push\");\nconst spdy = require(\"spdy\");\n\nconst app = express();\nconst server = spdy.createServer({\n  key: fs.readFileSync(\"path/to/key.pem\"),\n  cert: fs.readFileSync(\"path/to/cert.pem\"),\n  spdy: {\n    protocols: [\"h2\", \"http/1.1\"]\n  }\n}, app);\n\napp.get(\"/\",\n  stealPush(\"main\"),\n  function(req, res){\n    // Resources have already been pushed, just send the html\n    res.send(\"\u003cbody\u003eHello world!\u003c/body\u003e\");\n  });\n\napp.get(\"/order/details\",\n  stealPush(\"orders\"),\n  function(req, res){\n    res.send(\"\u003cbody\u003e\u003ch1\u003eOrders\u003c/h1\u003e ... \u003c/body\u003e\");\n  });\n\nserver.listen(8080);\n```\n\n### StealPush constructor\n\nThe `StealPush` constructor can be used to configure things such as the server root, and the location of the manifest file. Typical usage looks like:\n\n```js\nconst StealPush = require(\"steal-push\").StealPush;\n\nconst stealPush = new StealPush({\n\tmanifest: \"dist/bundles.json\",\n\troot: __dirname + \"/assets\",\n\tserverRoot: \"/app\"\n});\n\napp.get(\"/\",\n\tstealPush.for(\"main\"),\n\tfunction(req, res){\n\t\t...\n\t});\n```\n\n#### StealPush#for\n\nThe `for()` method on the StealPush object is used to create a function that takes a request and response object.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstealjs%2Fsteal-push","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstealjs%2Fsteal-push","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstealjs%2Fsteal-push/lists"}