UlrikHD

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:

  1. Does it make sense to use a GenServer to simply store and potentially update the session token of an account.
  2. Is there a different approach/convention that is typically used when implementing REST APIs in Elixir?
  3. Are there any pitfalls I should be aware while writing the library?

Most Liked

dimitarvp

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.

Where Next?

Popular in RFCs Top

tiagodavi
I’ve just created and published my first Elixir library! Ex4j combines the power of Ecto schema with the Bolt protocol + an elegant DSL ...
New
senconscious
EctoJuno is a package that provides parsing, validation and applying sorting parameters for your ecto queries on models. Currently sortin...
New
wingyplus
I just publish a library called redoc_ui_plug | Hex. The library renders Redoc UI from the openapi specification url. I used this library...
New
BartOtten
This lib is now published and has a new topic. Once this topic was about PhxAltRoutes. A lib pioneering localized routes for Phoenix. I...
New
dergraf
Hey everyone! :waving_hand: I’ve been working on a side project for the last 4 months that I’m excited to share—it’s called ProxyConf! P...
New
miolini
Hi :waving_hand: I’ve been working on CanvasCraft, a 2D drawing library for Elixir built on top of Skia via Rustler. It provides a decla...
New
bluzky
Hi everyone, I would like to introduce my new project OrangeCMS, it’s an application that help you to create/edit content post for your ...
New
brettbeatty
At my work we build a lot of mix tasks for backfills and other maintenance tasks. Even with OptionParser we seem to copy a lot of boilerp...
New
zachallaun
Hey gang, I’ve been using Req as my primary client for a project I’ve been working on that interacts with a number of APIs, and I quickl...
New
laibulle
Hello, I am playing with quantitative finance with Elixir. This library is more a way for me to explore and learn in this area and especi...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement