@rbxts/flamework-gateways-mod
Advanced tools
Comparing version 0.2.3 to 0.2.4
/** | ||
* Decorator that marks a class as a Gateway guard. Used for dependency | ||
* injection only. | ||
* @example | ||
* ```ts | ||
* const myGuard = Dependency(MyGuard); | ||
* ... | ||
* UseGuards(myGuard) | ||
* ``` | ||
* injection. | ||
* @example UseGuards(MyGuard) | ||
*/ | ||
@@ -11,0 +6,0 @@ export declare const Guard: (...args: void[]) => ((ctor: defined) => never) & { |
/** | ||
* Decorator that marks a class as a Gateway pipe. Used for dependency | ||
* injection only. | ||
* @example | ||
* ```ts | ||
* const myPipe = Dependency(MyPipe); | ||
* ... | ||
* UsePipes(myPipe) | ||
* ``` | ||
* injection. | ||
* @example UsePipes(MyPipe) | ||
*/ | ||
@@ -11,0 +6,0 @@ export declare const Pipe: (...args: void[]) => ((ctor: defined) => never) & { |
{ | ||
"name": "@rbxts/flamework-gateways-mod", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "A class-based Flamework networking mod", | ||
@@ -5,0 +5,0 @@ "main": "out/init.lua", |
@@ -20,7 +20,2 @@ <h1 align="center"> | ||
## ⚠️ Limitations | ||
❌ Client-side RemoteFunctions are not supported | ||
- It is difficult for the server to safely determine whether a client remote is a function or an event. | ||
## 🔌 Installation | ||
@@ -43,4 +38,9 @@ | ||
Do note that guards & pipes will not be applied to external listeners like `.on`, `.wait`, etc.! | ||
```ts | ||
type ServerGateway = OneGateway & AnotherGateway; | ||
const server = connectServer<ServerGateway, ClientGateway>(); | ||
server.emit("clientEvent", players, ...args); | ||
@@ -51,5 +51,8 @@ server.broadcast("clientEvent", ...args); | ||
```ts | ||
type ClientGateway = OneGateway & AnotherGateway; | ||
const client = connectClient<ServerGateway, ClientGateway>(); | ||
client.emit("serverEvent", ...args); | ||
await client.request("serverInvoke", ...args); | ||
client.request("serverInvoke", ...args); | ||
``` | ||
@@ -59,3 +62,3 @@ | ||
Gateways should be added to `Flamework.addPaths()`. | ||
Gateways should be added to `Flamework.addPaths()` | ||
@@ -70,6 +73,6 @@ ```ts | ||
@OnEvent() | ||
@UseGuards(CommandDebounceGuard) | ||
@UsePipes([], CommandPipe) | ||
async processCommand(player: Player, message: string): Promise<void>; | ||
async processCommand(player: Player, tokens: string | Array<string>) { | ||
this.adminService.runCommand(player, tokens as Array<string>); | ||
async processCommand(player: Player, message: string | Array<string>) { | ||
this.adminService.runCommand(player, message as Array<string>); | ||
} | ||
@@ -86,2 +89,4 @@ | ||
Creatable guards | ||
```ts | ||
@@ -91,3 +96,3 @@ class AdminGuard implements CanActivate { | ||
canActivate(context: ExecutionContext) | ||
canActivate(context: ExecutionContext) { | ||
return this.admins.includes(context.getPlayer().Name); | ||
@@ -98,4 +103,20 @@ } | ||
Singleton guards should be added to `Flamework.addPaths()` | ||
```ts | ||
@Guard() | ||
class CommandDebounceGuard implements CanActivate { | ||
constructor(private readonly roduxService: RoduxService) {} | ||
canActivate(context: ExecutionContext) { | ||
const state = this.roduxService.getState(); | ||
return time() >= state.commandDebounce; | ||
} | ||
} | ||
``` | ||
### 📞 Pipe | ||
Creatable pipe | ||
```ts | ||
@@ -109,1 +130,11 @@ class CommandPipe implements PipeTransform { | ||
``` | ||
Singleton pipes should be added to `Flamework.addPaths()` | ||
## ⚠️ Limitations | ||
❌ Client-side RemoteFunctions are not supported | ||
- It is difficult to safely determine whether a client remote is a function or an event from the server. | ||
❌ Some type limitations | ||
- Pipe transformation input/output is not type checked, use `Input | Output` in the parameter type to keep track (see examples). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74800
132
436