elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
9.1k stars 193 forks source link

Ability to create and remove websocket endpoints at runtime. #665

Open mavyfaby opened 1 month ago

mavyfaby commented 1 month ago

What is the problem this feature would solve?

Let's assume we have rooms that have multiple users; when there are no users in that room, the creator may formally remove it to save memory space and prevent any users from accessing the websocket endpoint/namespace.

What is the feature you are proposing to solve the problem?

As per the title, a function/method that can create and remove websocket endpoint at runtime.

My suggestion would be:

Declaration

const app = new Elysia();

app.ws("/room-1", {
   ...
});

Remove websocket namespace feature

...
app.remove("/room-1");
...

Add websocket namespace feature

...
app.ws("/room-1", { }); // Doesn't work during runtime
...

P.S: This feature may be also used for removing REST API endpoints.

What alternatives have you considered?

No response