{"id":21158162,"url":"https://github.com/node-casbin/pubsub-watcher","last_synced_at":"2025-03-14T15:27:03.260Z","repository":{"id":96121095,"uuid":"288140699","full_name":"node-casbin/pubsub-watcher","owner":"node-casbin","description":"Google Cloud Pub/Sub watcher for Node-Casbin","archived":false,"fork":false,"pushed_at":"2023-08-08T05:57:51.000Z","size":91,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-21T09:09:09.406Z","etag":null,"topics":["abac","acl","auth","authorization","authz","casbin","gcp","google-cloud","middleware","pubsub","rbac","watcher"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/node-casbin","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-casbin.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":"2020-08-17T09:41:08.000Z","updated_at":"2024-03-08T04:26:46.000Z","dependencies_parsed_at":"2024-11-20T21:31:03.429Z","dependency_job_id":null,"html_url":"https://github.com/node-casbin/pubsub-watcher","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-casbin%2Fpubsub-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-casbin%2Fpubsub-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-casbin%2Fpubsub-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-casbin%2Fpubsub-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-casbin","download_url":"https://codeload.github.com/node-casbin/pubsub-watcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243599767,"owners_count":20317156,"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":["abac","acl","auth","authorization","authz","casbin","gcp","google-cloud","middleware","pubsub","rbac","watcher"],"created_at":"2024-11-20T12:16:51.677Z","updated_at":"2025-03-14T15:27:03.238Z","avatar_url":"https://github.com/node-casbin.png","language":"JavaScript","readme":"# pubsub-watcher\n\n[![NPM version][npm-image]][npm-url]\n![CI](https://github.com/node-casbin/pubsub-watcher/workflows/CI/badge.svg)\n\n[npm-image]: https://img.shields.io/npm/v/@casbin/pubsub-watcher.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@casbin/pubsub-watcher\n\nGoogle Cloud Pub/Sub watcher for node-casbin\n\n# Installation\n\n```shell script\n# NPM\nnpm install --save @casbin/pubsub-watcher\n\n# Yarn\nyarn add @casbin/pubsub-watcher\n```\n\n# Simple Example\n\n```typescript\nimport { PubsubWatcher } from '@casbin/pubsub-watcher';\nimport { newEnforcer } from 'casbin';\n\n// Initialize the watcher.\n// You need to create Pubsub topic and subscription(per casbin instance) first\nconst watcher = await PubsubWatcher.newWatcher();\n\n// Initialize the enforcer.\nconst enforcer = await newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv');\n\nenforcer.setWatcher(watcher);\n\n// By default, the watcher's callback is automatically set to the\n// enforcer's loadPolicy() in the setWatcher() call.\n// We can change it by explicitly setting a callback.\nwatcher.setUpdateCallback(() =\u003e console.log('Casbin need update'));\n```\n\n# Test\n\nSet `GOOGLE_APPLICATION_CREDENTIALS` in environment variable and `npm run test`\n\nTest uses [Pub/Sub emulator](https://cloud.google.com/pubsub/docs/emulator)\n\n```sh\ngcloud beta emulators pubsub start --project=casbin\nPUBSUB_EMULATOR_HOST=localhost:8085 PUBSUB_PROJECT_ID=casbin npm run test\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-casbin%2Fpubsub-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-casbin%2Fpubsub-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-casbin%2Fpubsub-watcher/lists"}