{"id":15754783,"url":"https://github.com/miniscruff/scopie-js","last_synced_at":"2025-10-24T06:49:12.935Z","repository":{"id":221938781,"uuid":"740244858","full_name":"miniscruff/scopie-js","owner":"miniscruff","description":"JS implementation of scopie","archived":false,"fork":false,"pushed_at":"2024-03-15T09:02:37.000Z","size":93,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-03-15T10:24:34.935Z","etag":null,"topics":[],"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/miniscruff.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}},"created_at":"2024-01-07T23:33:51.000Z","updated_at":"2024-03-15T10:24:40.439Z","dependencies_parsed_at":"2024-03-15T10:24:34.991Z","dependency_job_id":null,"html_url":"https://github.com/miniscruff/scopie-js","commit_stats":null,"previous_names":["miniscruff/scopie-js"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniscruff%2Fscopie-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniscruff%2Fscopie-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniscruff%2Fscopie-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniscruff%2Fscopie-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miniscruff","download_url":"https://codeload.github.com/miniscruff/scopie-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246436381,"owners_count":20776995,"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":[],"created_at":"2024-10-04T08:04:50.728Z","updated_at":"2025-10-24T06:49:12.930Z","avatar_url":"https://github.com/miniscruff.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scopie\n\n[![NPM Version](https://img.shields.io/npm/v/scopie.svg?style=for-the-badge\u0026logoColor=white)](https://www.npmjs.com/package/scopie)\n[![NPM Downloads](https://img.shields.io/npm/dw/scopie?style=for-the-badge\u0026logoColor=white)](https://www.npmjs.com/package/scopie)\n\nJavascript implementation of [scopie](https://github.com/miniscruff/scopie).\n\nGenerated documentation can be viewed at [DOCS.md](./DOCS.md).\n\n## Example\n\n```js\nimport { isAllowed } from \"scopie\";\n\nconst users = {\n    elsa: {\n        rules: [\"allow/blog/create|update\"],\n    },\n    bella: {\n        rules: [\"allow/blog/create\"],\n    },\n]\nconst blogPosts = {}\n\nfunction createBlog(username, blogSlug, blogContent) {\n    const user = users[username]\n    if (isAllowed([\"blog/create\"], user.rules)) {\n        blogPosts[blogSlug] = {\n            author: user,\n            content: blogContent,\n        }\n    }\n}\n\nfunction updateBlog(username, blogSlug, blogContent) {\n    const user = users[username]\n    if (isAllowed([\"blog/update\"], user.rules)) {\n        blogPosts[blogSlug] = {\n            author: user,\n            content: blogContent,\n        }\n    }\n}\n```\n\n```typescript\nimport { isAllowed } from \"scopie\";\n\ntype User = {\n    rules: Array\u003cstring\u003e;\n};\n\ntype BlogPost = {\n    author: User;\n    content: string;\n}\n\ntype UserStore = {\n    [key: string]: User\n}\n\ntype BlogStore = {\n    [key: string]: BlogPost\n}\n\nconst users: UserStore = {\n    elsa: {\n        rules: [\"allow/blog/create|update\"],\n    },\n    bella: {\n        rules: [\"allow/blog/create\"],\n    },\n}\n\nconst blogPosts: BlogStore = {}\n\nfunction createBlog(username: string, blogSlug: string, blogContent: string) {\n    const user = users[username]\n    if (isAllowed([\"blog/create\"], user.rules)) {\n        blogPosts[blogSlug] = {\n            author: user,\n            content: blogContent,\n        }\n    }\n}\n\nfunction updateBlog(username: string, blogSlug: string, blogContent: string) {\n    const user = users[username]\n    if (isAllowed([\"blog/update\"], user.rules)) {\n        blogPosts[blogSlug] = {\n            author: user,\n            content: blogContent,\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminiscruff%2Fscopie-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminiscruff%2Fscopie-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminiscruff%2Fscopie-js/lists"}