{"id":27055332,"url":"https://github.com/dpskvn/express-sse","last_synced_at":"2025-04-05T09:20:08.646Z","repository":{"id":13731905,"uuid":"16426211","full_name":"dpskvn/express-sse","owner":"dpskvn","description":"An Express middleware for quick'n'easy server-sent events.","archived":false,"fork":false,"pushed_at":"2023-11-19T01:46:18.000Z","size":285,"stargazers_count":101,"open_issues_count":23,"forks_count":26,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-14T12:30:11.399Z","etag":null,"topics":["express-middleware","express-sse","javascript","nodejs","sse"],"latest_commit_sha":null,"homepage":"https://npmjs.org/package/express-sse","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/dpskvn.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":"2014-02-01T01:58:59.000Z","updated_at":"2024-06-18T13:46:43.209Z","dependencies_parsed_at":"2024-06-18T13:46:38.310Z","dependency_job_id":"e404ce01-5926-4576-a6c6-7904f21f9710","html_url":"https://github.com/dpskvn/express-sse","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpskvn%2Fexpress-sse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpskvn%2Fexpress-sse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpskvn%2Fexpress-sse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpskvn%2Fexpress-sse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dpskvn","download_url":"https://codeload.github.com/dpskvn/express-sse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312799,"owners_count":20918505,"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":["express-middleware","express-sse","javascript","nodejs","sse"],"created_at":"2025-04-05T09:20:08.131Z","updated_at":"2025-04-05T09:20:08.634Z","avatar_url":"https://github.com/dpskvn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"express-sse\n============\n\n[![npm version](https://badge.fury.io/js/express-sse.svg)](https://badge.fury.io/js/express-sse)  [![Build Status](https://travis-ci.org/dpskvn/express-sse.svg?branch=master)](https://travis-ci.org/dpskvn/express-sse)  [![Code Climate](https://codeclimate.com/github/dpskvn/express-sse/badges/gpa.svg)](https://codeclimate.com/github/dpskvn/express-sse)  [![codecov](https://codecov.io/gh/dpskvn/express-sse/branch/master/graph/badge.svg)](https://codecov.io/gh/dpskvn/express-sse)\n\n[![NPM](https://nodei.co/npm/express-sse.png?downloads=true)](https://nodei.co/npm/express-sse/)\n\nAn Express middleware for quick'n'easy server-sent events.\n\n## About\n`express-sse` is meant to keep things simple. You need to send server-sent events without too many complications and fallbacks? This is the library to do so.\n\n## Installation:\n`npm install --save express-sse`\n\nor\n\n`yarn add express-sse`\n\n## Usage example:\n### Options:\nYou can pass an optional options object to the constructor. Currently it only supports changing the way initial data is treated. If you set `isSerialized` to `false`, the initial data is sent as a single event. The default value is `true`.\n\n```js\nvar sse = new SSE([\"array\", \"containing\", \"initial\", \"content\", \"(optional)\"], { isSerialized: false, initialEvent: 'optional initial event name' });\n```\n\n### Server:\n```js\nvar SSE = require('express-sse');\nvar sse = new SSE([\"array\", \"containing\", \"initial\", \"content\", \"(optional)\"]);\n\n...\n\napp.get('/stream', sse.init);\n\n...\n\nsse.send(content);\nsse.send(content, eventName);\nsse.send(content, eventName, customID);\nsse.updateInit([\"array\", \"containing\", \"new\", \"content\"]);\nsse.serialize([\"array\", \"to\", \"be\", \"sent\", \"as\", \"serialized\", \"events\"]);\n```\n\n### Client:\n```js\nvar es = new EventSource('/stream');\n\nes.onmessage = function (event) {\n  ...\n};\n\nes.addEventListener(eventName, function (event) {\n  ...\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpskvn%2Fexpress-sse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdpskvn%2Fexpress-sse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpskvn%2Fexpress-sse/lists"}