Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
webdeb opened this issue Dec 27, 2019 · 0 comments
Open

Comments

@webdeb
Copy link

webdeb commented Dec 27, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant