Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
274 stars 57 forks source link

[Feature Request] Namespaced endpoints #341

Closed Darkle closed 1 year ago

Darkle commented 1 year ago

Hi, I think it would be super handy if it were possible to namespace endpoints, so that when using the client you could do something like this:

server.users.getUser id
server.users.addUser {|name="Foo"; id=2|}
server.posts.getPost id
Zaid-Ajaj commented 1 year ago

Hi there @Darkle, what you are asking for today is currently possible if you create multiple server protocols:

users.getUser 42
posts.getPost 1

where users and posts are two different protocols.

Although technically possible, adding namespacing to protocols would mean to nest the records inside other records. I feel like this overcomplicates the implementation and would require a different way to customize the routes. Using multiple protocols is the recommended way ✅

Darkle commented 1 year ago

Do you mean something like this?

let posts =
  Remoting.createApi ("http://localhost:3002")
  |> Remoting.buildProxy<PostsEndpoints>

let users =
  Remoting.createApi ("http://localhost:3002")
  |> Remoting.buildProxy<UsersEndpoints>
Zaid-Ajaj commented 1 year ago

Yes, exactly like that!

Darkle commented 1 year ago

Thanks.