tino415

tino415

Opinions for projects and architecture

Hello all,

after some years working with elixir, there are still some situations I don’t know how to clearly resolve, thinking about putting together some best practices for ecto and other tools. To make it easy I decided to start project and simply document all issues I came along. Besides that I’m also trying a lot of stuff (using plug and ecto without phoenix, schemas folder instead of domain driven design style). So I’m asking here for opinion, maybe some constructive critics etc GitHub - tino415/authex: Simple API only OAuth2/OpenID server · GitHub. So far I stumble on these:

  • I’m trying to follow CQRS and also to use changeset for most casting and validation
    but I think these things sometimes get in conflict. In this case I got to conflict
    when I was trying to validate creation of token. Because, in case o refresh token,
    I need casted refresh token from data to retrieve previous token to verify it validity,
    I resolved to what I always does, basically manually cast it in action (sort of controller)
    and pass selected token to changeset.

    Action:

    @impl true
    def create(conn, %{"code" => code} = params) do
      with %{} = flow <- Authex.get_flow_by_code_without_token(code) do
        do_create(conn, flow, params)
      else
        nil -> View.unauthorized(conn)
      end
    end
    
    def create(conn, %{"refresh_token" => refresh_token} = params) do
      with %{} = flow <- Authex.get_flow_by_refresh_token(refresh_token) do
        do_create(conn, flow, params)
      else
        nil -> View.unauthorized(conn)
      end
    end
    
    def create(conn, body_params) do
      do_create(conn, nil, body_params)
    end
    
  • I always tried to use put_assoc so result after inserting contains that association and
    I don’t need to return associated entity separately, but in this project it does not
    work. So I have this line after updating token:

      |> case do
        {:ok, client} -> {:ok, Repo.preload(client, scopes: :scope)}
        r -> r
      end
    

Where Next?

Popular in Discussions Top

sashaafm
I’m trying to evaluate the best combo/stack for a BEAM Web app. Right now I’m exploring Yaws a bit, after having dealt with Phoenix for a...
New
cvkmohan
The upcoming Phoenix 1.6 release looks very interesting. Became a habit to watch the commits - and - what they are bringing in. phx.gen...
New
jeramyRR
This is an interesting article to read. Elixir’s performance, like usual, is excellent. However, it seems like the high CPU usage is co...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
Fl4m3Ph03n1x
Background This question comes mainly from my ignorance. Today is Black Friday, one of my favorite days of the year to buy books. One boo...
New
arpan
Hello everyone :wave: Today I am very excited to announce a project that I have been working on for almost 3 months now. The project is...
New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
IVR
Hi all, I’ve seen a number of related threads in the past, but I’d still be very curious to hear an up-to-date opinion on this topic. I...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
100phlecs
Are there any downsides, like perf issues, to putting all functional components in CoreComponents as long as you prefix it with the conte...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

We're in Beta

About us Mission Statement