{"id":17676264,"url":"https://github.com/glamboyosa/ore","last_synced_at":"2025-05-08T17:01:39.035Z","repository":{"id":230061346,"uuid":"777985200","full_name":"glamboyosa/ore","owner":"glamboyosa","description":"Fully typed SSE library for handling server-sent events on the client and in React Server Components.","archived":false,"fork":false,"pushed_at":"2024-06-18T19:17:32.000Z","size":20368,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-08T17:00:07.481Z","etag":null,"topics":["library","oss","react-server-components","rsc","server-sent-events","sse","sse-client"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@glamboyosa/ore","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glamboyosa.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":null,"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-03-26T21:40:32.000Z","updated_at":"2024-12-11T13:13:23.000Z","dependencies_parsed_at":"2024-10-24T09:33:07.366Z","dependency_job_id":"01c4c428-52db-48a0-a2f0-2b6a9e5eb183","html_url":"https://github.com/glamboyosa/ore","commit_stats":null,"previous_names":["glamboyosa/ore"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glamboyosa%2Fore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glamboyosa%2Fore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glamboyosa%2Fore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glamboyosa%2Fore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glamboyosa","download_url":"https://codeload.github.com/glamboyosa/ore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253112071,"owners_count":21856070,"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":["library","oss","react-server-components","rsc","server-sent-events","sse","sse-client"],"created_at":"2024-10-24T07:24:56.072Z","updated_at":"2025-05-08T17:01:38.770Z","avatar_url":"https://github.com/glamboyosa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ore\n\nOre is a JavaScript / TypeScript package that simplifies the consumption of Server-Sent Events (SSE) in web applications. It provides an easy-to-use interface for establishing SSE connections, handling incoming events, and implementing retry strategies in case of connection failures.\n\n## Motivation\n\nConsuming Server-Sent Events (SSE) or streaming data in web applications isn't always well-documented and can be complex or just plain unreliable to implement. Ore aims to simplify this process by providing a straightforward and reliable way to consume SSE streams.\n\n## Features\n\n- Establish SSE connections with ease.\n- Handle incoming SSE events and process them accordingly.\n- Implement retry strategies for reconnecting to the SSE endpoint in case of connection failures.\n- Customizable headers for SSE requests.\n- Set maximum retries for connection attempts.\n\n## Install\n\n```bash\nnpm install @glamboyosa/ore\n```\n\n## Usage\n\n```typescript\nimport Ore from \"@glamboyosa/ore\";\n\n// Initialize Ore with URL and optional headers\nconst ore = new Ore({\n  url: \"http://example.com/sse-endpoint\",\n  headers: {\n    \"Cache-Control\": \"no-cache\",\n  },\n});\n\n// Start SSE connection\nore.fetchSSE(\n  (buffer, parts) =\u003e {\n    console.log(\"Received buffer:\", buffer);\n    // Process the received buffer\n\n    const b = parts[parts.length - 1];\n    console.log(\"Received parts i.e. events\", parts);\n    console.log(\"Buffer per event\", b);\n    // process the buffer per event\n  },\n  () =\u003e {\n    console.log(\"Stream ended\");\n    // Handle stream end\n  }\n);\n```\n\n## Class Parameters\n\n- `url`: `string` - The URL of the SSE endpoint.\n- `headers`: `HeadersInit` (optional) - Optional headers to include in the SSE request. Must be an object where keys are header names and values are header values.\n\n## `fetchSSE` Function Parameters\n\n- `onBufferReceived`: `function` - Callback function to handle received SSE buffers. Receives the buffer and the optionally the parts i.e. new events as a parameter.\n- `onStreamEnded`: `function` - Callback function to handle stream end events. Receives the internal state of if the buffer stream is ended.\n- `retries`: `number` (optional) - Optional parameter to specify the maximum number of retry attempts. Default is 3.\n\n## Working with React Server Components\n\nWhile Ore is intended to work with client components, it is possible to use it in server components using the `fetchSSEForRSC` function. The function takes optional `retries`: `number` (optional) - Optional parameter to specify the maximum number of retry attempts. Default is 3. and `customHeaders`: `HeadersInit` (optional) - Optional headers to include in the SSE request. Must be an object where keys are header names and values are header values.\n\n### Usage with RSCs\n\nCheckout the `next-js-example` directory for a full example on how to use it with Server Components [here](https://github.com/glamboyosa/ore/blob/main/examples/next-js-example/src/app/page.tsx)\n\n## Contributing\n\nContributions to @glamboyosa/ore are welcome! If you have suggestions for improvements or encounter any issues, feel free to open an issue or submit a pull request on GitHub.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglamboyosa%2Fore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglamboyosa%2Fore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglamboyosa%2Fore/lists"}