{"id":31936446,"url":"https://github.com/stitchng/adonis-sse","last_synced_at":"2025-10-14T07:42:50.238Z","repository":{"id":55478645,"uuid":"216003718","full_name":"stitchng/adonis-sse","owner":"stitchng","description":"An addon/plugin package to provide server-sent events functionality for AdonisJS 4.0+","archived":false,"fork":false,"pushed_at":"2020-12-28T10:33:50.000Z","size":71,"stargazers_count":17,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-06T17:38:13.668Z","etag":null,"topics":["adonisjs","event-streaming","eventsource","server-sent-event"],"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/stitchng.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":"coolcodes","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-10-18T10:54:35.000Z","updated_at":"2023-09-19T22:03:27.000Z","dependencies_parsed_at":"2022-08-15T01:20:10.965Z","dependency_job_id":null,"html_url":"https://github.com/stitchng/adonis-sse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stitchng/adonis-sse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stitchng%2Fadonis-sse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stitchng%2Fadonis-sse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stitchng%2Fadonis-sse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stitchng%2Fadonis-sse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stitchng","download_url":"https://codeload.github.com/stitchng/adonis-sse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stitchng%2Fadonis-sse/sbom","scorecard":{"id":853483,"data":{"date":"2025-08-11","repo":{"name":"github.com/stitchng/adonis-sse","commit":"d7703e526b40e5259ce14ce46f4485736d3fca4f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":1,"reason":"Found 2/19 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 13 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T23:10:41.373Z","repository_id":55478645,"created_at":"2025-08-23T23:10:41.373Z","updated_at":"2025-08-23T23:10:41.373Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279015307,"owners_count":26085684,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["adonisjs","event-streaming","eventsource","server-sent-event"],"created_at":"2025-10-14T07:42:45.136Z","updated_at":"2025-10-14T07:42:50.232Z","avatar_url":"https://github.com/stitchng.png","language":"JavaScript","funding_links":["https://patreon.com/coolcodes","https://www.patreon.com/coolcodes/"],"categories":[],"sub_categories":[],"readme":"# adonis-sse\nAn addon/plugin package to provide server-sent events functionality for AdonisJS 4.0+\n\n[![NPM Version][npm-image]][npm-url]\n[![Build Status][travis-image]][travis-url]\n[![Coveralls][coveralls-image]][coveralls-url]\n\n\u003cimg src=\"http://res.cloudinary.com/adonisjs/image/upload/q_100/v1497112678/adonis-purple_pzkmzt.svg\" width=\"200px\" align=\"right\" hspace=\"30px\" vspace=\"140px\"\u003e\n\n## Getting Started\n```bash\n\n    adonis install adonisjs-sse\n\n```\n\n## Usage\n\n\u003eFirstly, follow the instructions in `instructions.md` file to setup the *Provider* and *Middleware*\n\nSee the [_instructions.md_](https://github.com/stitchng/adonis-sse/blob/master/instructions.md) file for the complete installation steps and follow as stated.\n\n### Registering provider\n\nLike any other provider, you need to register the provider inside `start/app.js` file.\n\n```js\nconst providers = [\n  ...\n  'adonisjs-sse/providers/ServerSentEventsProvider',\n]\n```\n### Registering middleware\n\nRegister the following middleware inside `start/kernel.js` file. \n\n\u003eYou can optionally place the sse middleware after the 'Adonis/Middleware/AuthInit' middleware\n\n```js\nconst globalMiddleware = [\n  ...\n  'Adonis/Middleware/AuthInit',\n  'Adonis/Middleware/EventSourceWatcher'\n]\n```\n\u003eOr alternatively setup the middleware as a named (use any name you feel like) middleware inside `start/kernel.js` file.\n\n```js\n\nconst namedMiddleware = {\n  eventsource: 'Adonis/Middleware/EventSourceWatcher'\n}\n\n```\n\n*HINT: It would be much easier and better to make the `EventSourceWatcher` middleware a global middleware*\n\n\u003eSetup serve-sent events route inside `start/routes.js` file.\n\n```js\n\n/** @type {typeof import('@adonisjs/framework/src/Route/Manager')} */\nconst Route = use('Route');\n\n/**\n * If the 'eventsource' named middleware is set\n * then setup route like below\n */\nRoute.get('/stream', ({ source }) =\u003e {\n      // send a server-sent events comment\n      source.send(\"Hello AdonisJS\", '!This is a comment!');\n}).middleware(['eventsource']);\n\n/**\n * If the middleware is a global middlware\n * then setup route like below\n */\nRoute.get('/stream', ({ source }) =\u003e {\n      // send a server-sent events comment\n      source.send(\"Hello AdonisJS\", '!This is a comment!');\n})\n\nRoute.post('/send/email', 'NotificationsController.sendEmail')\n\n```\n\n## Example(s)\n\n\u003eSetup a controller to dispatch server-sent events to the browser using the `source.send(data: Object, comment: String, event: String, retry: Number)` method like so:\n\n```js\n\n/** @type {typeof import('@adonisjs/mail/src/Mail')} */\nconst Mail = use('Mail')\n\nclass NotificationsController {\n\n    async sendEmail ({ request, auth, source }){\n\n        let input = request.only([\n            'ticket_user_id'\n        ]);\n\n        let { id, email, fullname } = await auth.getUser();\n        let error = false\n\n\t\ttry{\n\n\t\t\tawait Mail.send(\n                'emails.template', \n                { fullname }, (message) =\u003e {\n\t\t\t\tmessage.to(email) \n\t\t\t\tmessage.from('crm.tickets@funsignals.co') \n\t\t\t\tmessage.subject('Ticket Creation Job Status')\n            })\n            \n\t\t}catch(err){\n            \n            error = true\n            \n\t\t}finally{\n\n            source.send({\n                ticket_reciever: id,\n                ticket_creator: input.ticket_user_id,\n                ticket_mail_status: `email sent ${error ? 'un' : ''}successfuly`\n            }, null, 'update', 4000) // event: 'update', retry: 4000 (4 seconds)\n\t\t\t\n        }\n    }\n}\n\nmodule.exports = NotificationsController\t\t\n```\n\n```typescript\n\n/**\n * source.send (METHOD)\n */\n\nsend( data: object, comment: string, event: string, retry: number );\n\n```\n\n## Connecting from the client-side\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003c!-- Polyfill for older browsers without native support for the HTML5 EventSource API. --\u003e\n    \u003cscript src=\"https://cdn.polyfill.io/v2/polyfill.min.js?features=EventSource\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n     \u003cscript id=\"server-side-events\" type=\"text/javascript\"\u003e\n\t     const stream = new EventSource(\"http://127.0.0.1:3333/stream\");\n\t     \n\t     stream.addEventListener('message', function(e){\n                 console.log(\"Data: \", e.data);\n\t     }, false);\n\t     \n\t     stream.addEventListener('open', function(e) {\n\t\t// Connection was opened.\n\t        console.log('connection open: true');\n\t     }, false);\n\n\t     stream.addEventListener('error', function(e) {\n\t\t  if (e.readyState == EventSource.CLOSED) {\n\t\t    // Connection was closed.\n\t            console.log('connection closed: true');\n\t\t  }\n\t     }, false);\n     \u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## License\n\nMIT\n\n## Running Tests\n```bash\n\n    npm i\n\n```\n\n```bash\n\n    npm run lint\n    \n    npm run test\n\n```\n\n## Credits\n\n- [Ifeora Okechukwu](https://twitter.com/isocroft)\n\n## Contributing\n\nSee the [CONTRIBUTING.md](https://github.com/stitchng/adonis-sse/blob/master/CONTRIBUTING.md) file for info\n\n[npm-image]: https://img.shields.io/npm/v/adonisjs-sse.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/adonisjs-sse\n\n[travis-image]: https://img.shields.io/travis/stitchng/adonis-sse/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/stitchng/adonis-sse\n\n[coveralls-image]: https://img.shields.io/coveralls/stitchng/adonis-sse/master.svg?style=flat-square\n\n[coveralls-url]: https://coveralls.io/github/stitchng/adonis-sse\n\n## Support \n\n**Coolcodes** is a non-profit software foundation (collective) created by **Oparand** - parent company of StitchNG, Synergixe based in Abuja, Nigeria. You'll find an overview of all our work and supported open source projects on our [Facebook Page](https://www.facebook.com/coolcodes/).\n\n\u003eFollow us on facebook if you can to get the latest open source software/freeware news and infomation.\n\nDoes your business depend on our open projects? Reach out and support us on [Patreon](https://www.patreon.com/coolcodes/). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstitchng%2Fadonis-sse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstitchng%2Fadonis-sse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstitchng%2Fadonis-sse/lists"}