{"id":17291338,"url":"https://github.com/cxres/express-accept-events","last_synced_at":"2025-04-14T11:51:44.118Z","repository":{"id":247658497,"uuid":"825896784","full_name":"CxRes/express-accept-events","owner":"CxRes","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-08T23:20:24.000Z","size":105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T01:01:40.118Z","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":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CxRes.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":"2024-07-08T17:58:29.000Z","updated_at":"2024-10-08T23:10:48.000Z","dependencies_parsed_at":"2024-07-10T00:35:38.686Z","dependency_job_id":null,"html_url":"https://github.com/CxRes/express-accept-events","commit_stats":null,"previous_names":["cxres/express-accept-events"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CxRes%2Fexpress-accept-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CxRes%2Fexpress-accept-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CxRes%2Fexpress-accept-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CxRes%2Fexpress-accept-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CxRes","download_url":"https://codeload.github.com/CxRes/express-accept-events/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248877986,"owners_count":21176239,"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-10-15T10:40:47.277Z","updated_at":"2025-04-14T11:51:44.057Z","avatar_url":"https://github.com/CxRes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express Accept Events\n\nA Connect/Express style middleware to parse the `Accept-Events` header field specified in [Per Resource Events](https://cxres.github.io/prep/draft-gupta-httpbis-per-resource-events.html).\n\n## Installation\n\nInstall **Express Accept Events** using your favourite package manager.\n\n```sh\nnpm|pnpm|yarn|bun add express-accept-events\n```\n\n## Usage\n\nIn case one is using an Express server:\n\n```js\nimport AcceptEvents from \"express-accept-events\";\nconst app = express();\napp.use(acceptEvents);\n```\n\nThe middleware populates `req.acceptEvents` with a list of notification protocols and their corresponding parameters (sorted by the value of a `q` parameter, if provided) in `GET` and `POST` requests. For Example, the following HTTP request:\n\n```http\nGET /notifications HTTP/1.1\nHost: example.com\nAccept: text/plain\nAccept-Events: \"prep\"; accept=\"message/rfc822\"; q=0.9, \"solid\"; type=\"WebSocket2023\"\n```\n\nwith the GET handler, so specified:\n\n```js\napp.get(\"/foo\", (req, res) =\u003e {\n  console.log(req.acceptEvents);\n});\n```\n\nwill result in the output:\n\n```sh\n[\n  [ \"solid\", Map(1) { \"type\" =\u003e \"WebSocket2023\" } ]\n  [ \"prep\", Map(2) { \"accept\" =\u003e \"message/rfc822\", \"q\" =\u003e 0.9 } ]\n]\n```\n\n## Errors\n\nIn case the middleware fails to parse the `Accept-Events` header field, the `req.acceptEvents` property is not created.\n\n## Copyright and License\n\nCopyright © 2024, [Rahul Gupta](https://cxres.pages.dev/profile#i) and Express Accept Events contributors.\n\nThe source code in this repository is released under the [Mozilla Public License v2.0](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxres%2Fexpress-accept-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcxres%2Fexpress-accept-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxres%2Fexpress-accept-events/lists"}