Skip to content

Elixir Script as ClientLibrary Framework to Interface with Elixir/Phoenix  #494

Open
@webdeb

Description

@webdeb

Are there any thoughts about creating a client framework for interactions with a Phoenix Backend.
Like programmatically mapping resources/routes, error handling (messages) etc.

Would make sense I guess, so for example, interaction with Modules, GenServers etc.
One could just get the generated script directly from the server.

Just consider the following idea:

defmodule API.Accounts do
  use ClientInterface, "Accounts"
  
  api("getUser", jwt, id \\ nil) do
      Accounts.get_user(id || jwt.userId)
  end
end
<script src="/backend-api.js?module=MyAPI"></script>
<script>
MyAPI.Accounts.getUser()
  .then(me => {
    // got the current user, as there were no id specified
  }).catch(e => {
    // handle error
  })
</script>

I think, that such a framework would make rapid development of apis and adoption of elixir very smooth. It would be possible to build other interfaces like sockets and such on top of that very straightforward.

Would like to know, what the community thinks about it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions