Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rbxts/flamework-gateways-mod

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rbxts/flamework-gateways-mod

A class-based Flamework networking mod

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

🌉flamework-gateways-mod🌉

A Flamework networking mod

✨ Featuring

🌉 Gateways - Handle remote events and functions with classes

🛡️ Guards - Block certain requests before they are processed

📞 Pipes - Transform and validate parameters passed to requests

🌻 Motivation

This is mainly a personal project to handle remotes with classes and decorators.

⚠️ 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

npm install @flamework/core@modding
npm install -D rbxts-transformer-flamework@modding
npm install @rbxts/flamework-gateways-mod

📚 Examples

🗂️ Client-server connection

connectServer and connectClient should be called before igniting Flamework.

const server = connectServer<ServerGateway, ClientGateway>();
server.emit("clientEvent", players, ...args);
server.broadcast("clientEvent", ...args);
const client = connectClient<ServerGateway, ClientGateway>();
client.emit("serverEvent", ...args);
await client.request("serverInvoke", ...args);

🌉 Gateway

Gateways should be added to Flamework.addPaths().

@Gateway({
  guards: [new AdminGuard(["littensy"])],
})
class AdminGateway {
  constructor(private readonly adminService: AdminService) {}

  @OnEvent()
  @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>);
  }

  @OnInvoke()
  async getCommands() {
    return this.adminService.getCommands();
  }
}

🛡️ Guard

class AdminGuard implements CanActivate {
  constructor(private readonly admins: Array<string>) {}

  canActivate(context: ExecutionContext) 
    return this.admins.includes(context.getPlayer().Name);
  }
}

📞 Pipe

class CommandPipe implements PipeTransform {
  transform(value: unknown) {
    assert(typeIs(value, "string"), "(CommandPipe) Value must be a string");
    return value.split(" ");
  }
}

Keywords

FAQs

Package last updated on 17 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc