{"analyzedAt":"2022-07-06T09:14:00.865Z","collected":{"metadata":{"name":"@rbxts/flamework-gateways-mod","scope":"rbxts","version":"0.2.4","description":"A class-based Flamework networking mod","keywords":["flamework","roblox-ts","networking"],"date":"2021-12-17T03:54:45.648Z","author":{"name":"littensy"},"publisher":{"username":"littensy","email":"richerd.rdc@gmail.com"},"maintainers":[{"username":"littensy","email":"richerd.rdc@gmail.com"}],"repository":{"type":"git","url":"git+https://github.com/littensy/flamework-gateways-mod.git"},"links":{"npm":"https://www.npmjs.com/package/%40rbxts%2Fflamework-gateways-mod","homepage":"https://github.com/littensy/flamework-gateways-mod#readme","repository":"https://github.com/littensy/flamework-gateways-mod","bugs":"https://github.com/littensy/flamework-gateways-mod/issues"},"license":"ISC","dependencies":{"@flamework/core":"^1.0.0-beta.modding.1","@rbxts/make":"^1.0.6","@rbxts/object-utils":"^1.0.4","@rbxts/services":"^1.2.0","@rbxts/t":"^3.0.0"},"devDependencies":{"@rbxts/compiler-types":"^1.2.7-types.1","@rbxts/types":"^1.0.557","@typescript-eslint/eslint-plugin":"^5.6.0","@typescript-eslint/parser":"^5.6.0","eslint":"^8.3.0","eslint-config-prettier":"^8.3.0","eslint-plugin-jsdoc":"^37.0.3","eslint-plugin-prettier":"^4.0.0","eslint-plugin-roblox-ts":"0.0.32","eslint-plugin-simple-import-sort":"^7.0.0","eslint-plugin-sort-imports-es6-autofix":"^0.6.0","eslint-plugin-unused-imports":"^1.1.5","prettier":"^2.5.1","rbxts-transformer-flamework":"^1.0.0-beta.modding.0","roblox-ts":"^1.2.7","typescript":"^4.4.4"},"releases":[{"from":"2022-06-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-04-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-01-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":1},{"from":"2021-07-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":13},{"from":"2020-07-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":13}],"hasSelectiveFiles":true,"readme":"<h1 align=\"center\">\r\n  <code>🌉flamework-gateways-mod🌉</code>\r\n  <br>\r\n</hi>\r\n\r\n<h4 align=\"center\">A Flamework networking mod</h4>\r\n\r\n## ✨ Featuring\r\n\r\n🌉 Gateways - Handle remote events and functions with classes\r\n\r\n🛡️ Guards - Block certain requests before they are processed\r\n\r\n📞 Pipes - Transform and validate parameters passed to requests\r\n\r\n## 🌻 Motivation\r\n\r\nThis is mainly a personal project to handle remotes with classes and decorators.\r\n\r\n## 🔌 Installation\r\n\r\n```\r\nnpm install @flamework/core@modding\r\nnpm install -D rbxts-transformer-flamework@modding\r\n```\r\n\r\n```\r\nnpm install @rbxts/flamework-gateways-mod\r\n```\r\n\r\n## 📚 Examples\r\n\r\n### 🗂️ Client-server connection\r\n\r\n`connectServer` and `connectClient` should be called before igniting Flamework.\r\n\r\nDo note that guards & pipes will not be applied to external listeners like `.on`, `.wait`, etc.!\r\n\r\n```ts\r\ntype ServerGateway = OneGateway & AnotherGateway;\r\n\r\nconst server = connectServer<ServerGateway, ClientGateway>();\r\n\r\nserver.emit(\"clientEvent\", players, ...args);\r\nserver.broadcast(\"clientEvent\", ...args);\r\n```\r\n\r\n```ts\r\ntype ClientGateway = OneGateway & AnotherGateway;\r\n\r\nconst client = connectClient<ServerGateway, ClientGateway>();\r\n\r\nclient.emit(\"serverEvent\", ...args);\r\nclient.request(\"serverInvoke\", ...args);\r\n```\r\n\r\n### 🌉 Gateway\r\n\r\nGateways should be added to `Flamework.addPaths()`\r\n\r\n```ts\r\n@Gateway({\r\n  guards: [new AdminGuard([\"littensy\"])],\r\n})\r\nclass AdminGateway {\r\n  constructor(private readonly adminService: AdminService) {}\r\n\r\n  @OnEvent()\r\n  @UseGuards(CommandDebounceGuard)\r\n  @UsePipes([], CommandPipe)\r\n  async processCommand(player: Player, message: string | Array<string>) {\r\n    this.adminService.runCommand(player, message as Array<string>);\r\n  }\r\n\r\n  @OnInvoke()\r\n  async getCommands() {\r\n    return this.adminService.getCommands();\r\n  }\r\n}\r\n```\r\n\r\n### 🛡️ Guard\r\n\r\nCreatable guards\r\n\r\n```ts\r\nclass AdminGuard implements CanActivate {\r\n  constructor(private readonly admins: Array<string>) {}\r\n\r\n  canActivate(context: ExecutionContext) {\r\n    return this.admins.includes(context.getPlayer().Name);\r\n  }\r\n}\r\n```\r\n\r\nSingleton guards should be added to `Flamework.addPaths()`\r\n\r\n```ts\r\n@Guard()\r\nclass CommandDebounceGuard implements CanActivate {\r\n  constructor(private readonly roduxService: RoduxService) {}\r\n\r\n  canActivate(context: ExecutionContext) {\r\n    const state = this.roduxService.getState();\r\n    return time() >= state.commandDebounce;\r\n  }\r\n}\r\n```\r\n\r\n### 📞 Pipe\r\n\r\nCreatable pipe\r\n\r\n```ts\r\nclass CommandPipe implements PipeTransform {\r\n  transform(value: unknown) {\r\n    assert(typeIs(value, \"string\"), \"(CommandPipe) Value must be a string\");\r\n    return value.split(\" \");\r\n  }\r\n}\r\n```\r\n\r\nSingleton pipes should be added to `Flamework.addPaths()`\r\n\r\n## ⚠️ Limitations\r\n\r\n❌ Client-side RemoteFunctions are not supported\r\n - It is difficult to safely determine whether a client remote is a function or an event from the server.\r\n\r\n❌ Some type limitations\r\n - Pipe transformation input/output is not type checked, use `Input | Output` in the parameter type to keep track (see examples)."},"npm":{"downloads":[{"from":"2022-07-05T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-06-29T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":5},{"from":"2022-06-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":8},{"from":"2022-04-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":100},{"from":"2022-01-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":217},{"from":"2021-07-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":593}],"starsCount":0},"github":{"homepage":"https://www.npmjs.com/package/@rbxts/flamework-gateways-mod","starsCount":3,"forksCount":0,"subscribersCount":2,"issues":{"count":4,"openCount":2,"distribution":{"3600":0,"10800":0,"32400":0,"97200":1,"291600":1,"874800":0,"2624400":0,"7873200":0,"23619600":2,"70858800":0,"212576400":0},"isDisabled":false},"contributors":[{"username":"littensy","commitsCount":36}],"commits":[{"from":"2022-06-29T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-06-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-04-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-01-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2021-07-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":36}]},"source":{"files":{"readmeSize":3109,"testsSize":8222},"linters":["eslint","prettier"]}},"evaluation":{"quality":{"carefulness":0.45999999999999996,"tests":0.3,"health":1,"branding":0},"popularity":{"communityInterest":6,"downloadsCount":33.333333333333336,"downloadsAcceleration":-0.4442732115677322,"dependentsCount":0},"maintenance":{"releasesFrequency":0.7565924657534246,"commitsFrequency":0.41424657534246584,"openIssues":0.5,"issuesDistribution":0.482035886205808}},"score":{"final":0.5646770546978663,"detail":{"quality":0.6947624134360788,"popularity":0.03800900783739058,"maintenance":0.9798433654970172}}}