{"id":19253634,"url":"https://github.com/mono-js/mono-push","last_synced_at":"2026-05-14T01:42:10.368Z","repository":{"id":57165604,"uuid":"106042715","full_name":"mono-js/mono-push","owner":"mono-js","description":"Push module for Mono","archived":false,"fork":false,"pushed_at":"2018-08-20T23:22:34.000Z","size":315,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-14T12:55:01.099Z","etag":null,"topics":["mono","mono-module","push","socket-io"],"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/mono-js.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}},"created_at":"2017-10-06T19:29:12.000Z","updated_at":"2018-08-20T23:22:35.000Z","dependencies_parsed_at":"2022-08-30T15:21:18.045Z","dependency_job_id":null,"html_url":"https://github.com/mono-js/mono-push","commit_stats":null,"previous_names":["terrajs/mono-push"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/mono-js/mono-push","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono-js%2Fmono-push","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono-js%2Fmono-push/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono-js%2Fmono-push/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono-js%2Fmono-push/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mono-js","download_url":"https://codeload.github.com/mono-js/mono-push/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono-js%2Fmono-push/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29414342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["mono","mono-module","push","socket-io"],"created_at":"2024-11-09T18:32:22.278Z","updated_at":"2026-02-13T19:01:04.309Z","avatar_url":"https://github.com/mono-js.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/904724/31862570-6cab4562-b740-11e7-8cb2-c608548cbc31.png\" width=\"350\" alt=\"Mono Push\"/\u003e\u003c/h1\u003e\n\n\u003e Push module for [Mono](https://github.com/terrajs/mono)\n\n[![npm version](https://img.shields.io/npm/v/mono-push.svg)](https://www.npmjs.com/package/mono-push)\n[![Travis](https://img.shields.io/travis/terrajs/mono-push/master.svg)](https://travis-ci.org/terrajs/mono-push)\n[![Coverage](https://img.shields.io/codecov/c/github/terrajs/mono-push/master.svg)](https://codecov.io/gh/terrajs/mono-push.js)\n[![license](https://img.shields.io/github/license/terrajs/mono-push.svg)](https://github.com/terrajs/mono-push/blob/master/LICENSE)\n\n## Installation\n\n```bash\nnpm install --save mono-push\n```\n\nThen, in your configuration file of your Mono application (example: `conf/application.js`):\n\n```js\nmodule.exports = {\n  mono: {\n    modules: [\n      'mono-mongodb',\n      'mono-push'\n    ]\n  }\n}\n```\n\nmono-push requires [mono-mongodb](https://github.com/terrajs/mono-mongodb), so it must be installed and declared before mono-push because modules are loaded synchronously\n\n## Configuration\n\nmono-push will use the `push` property of your configuration:\n\n- `io`: Activate push event via [socket.io](https://socket.io)\n  - Type: `boolean`\n  - Default: `false`\n  - Requires: [mono-io](https://github.com/terrajs/mono-io)\n- `collectionName`: Collection name in [MongoDB](https://www.mongodb.com)\n  - Type: `string`\n  - Default: `'mono-pushes'`\n\nExample of activating `socket.io` and writing events in `pushes` collection (`conf/application.js`):\n\n```js\nmodule.exports = {\n  mono: {\n    modules: [\n      'mono-mongodb', // Required by mono-push\n      'mono-io', // Required by mono-push when io is true\n      'mono-push'\n    ],\n    push: {\n      io: true,\n      collectionName: 'pushes'\n    }\n  }\n}\n```\n\n## Usage\n\nIn your files, you can access the `push` and `pushAll` methods like this:\n\n### Push an event to authenticated user(s) matching a query\n\n`push(event: string, query: object = {}, payload: object = {})`\n\n### Push an event to all connected sockets\n\n`pushAll(event: string, payload: object = {})`\n\n## Example\n\n```js\nconst { push, pushAll } = require('mono-push')\n\nawait push('notification', { userId: '...' }, { type: 'email' })\n// userId will be matched against authenticated users\n\nawait pushAll('message', { message: 'Welcome!' })\n// Send it to all connected devices\n```\n\nWith conf `io: true`, mono-push will emit an event to every socket connected that matches the query.\n\nOn client-side, the user must connect with the [socket.io-client](https://github.com/socketio/socket.io-client):\n\n```js\nimport io from 'socket.io-client'\n\nconst socket = io('http://localhost:8000/push')\n\nconst token = '...' // JWT generate by await jwt.generateJWT(session), see Mono\n\nsocket.on('connect', () =\u003e {\n  socket\n    .emit('authenticate', { token })\n    .on('authenticated', function () {\n      console.log('Authenticated')\n    })\n    .on('unauthorized', function (msg) {\n      console.log('Unauthorized')\n    })\n\n  // Listen on push events\n  socket.on('my-event', (event) {\n    // event is { message: 'Welcome!' }\n  })\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmono-js%2Fmono-push","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmono-js%2Fmono-push","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmono-js%2Fmono-push/lists"}