UlrikHD
Any tips on implenting the lemmy api?
I’ve been wanting to write a library for the lemmy API so that I can port some of my scripts over to elixir. For those unfamiliar with lemmy, it’s a FOSS project trying to mimic reddit.
Since I’ve only used elixir for a single project/5 months, I’d like to know if my idea for the library structure is sound.
My current plan is to use req as a dependency to take care of the network of communication. I’m leaning towards using a GenServer process to store the JSON Web Token for an account login, and then have all API calls on the format api_call(GenServer_PID, api_params...). The api_call will then make a GenServer call to retrieve the JWT before sending the request.
The advantage of this format is that you can easily juggle multiple accounts/processes in the same VM process if you want to wrap up and supervise multiple scripts in one process. The disadvantage is that all calls have to go through the GenServer process to retrieve the JWT, though I don’t think this is a realistic bottleneck.
I suppose my questions are:
- Does it make sense to use a GenServer to simply store and potentially update the session token of an account.
- Is there a different approach/convention that is typically used when implementing REST APIs in Elixir?
- Are there any pitfalls I should be aware while writing the library?
Most Liked
dimitarvp
The BEAM VM has zero sandboxing abilities. One process running malicious code can extract a lot of information. It’s best that you don’t concern yourself with this; assume the code in your application is safe and do worry only about interacting with the external world. Using a secrets manager to inject the values that your application needs is also pretty much the accepted approach for years now.
Popular in RFCs
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









