Gonza

Gonza

Igniter for Express -> Ash rewrite?

Hey, I’m thinking about migrating a NodeJS backend to Ash. It’s one of those times in the life of a project where you start to think a full rewrite would be cheaper and better than fixing everything that’s been breaking up along the way.
Anyways, I was exploring a little the new Igniter project, and it got me thinking: is it a crazy idea if I try to replicate the old API surface via generators? It is a pretty standard REST interface with just a handful of main routes.
I know there’s going to be a lot of manual work migrating the actual core of the app and all the business rules, but the contract with the frontend clients is the one thing that must not change. Is this a good use case for using Igniter?
The general idea is to:

  1. Create and/or update a comprehensive OpenAPI spec of the entire existing backend
  2. Infer from there what the new resources should look like and transform this into Igniter commands (can probably be automated to a degree)
  3. Run the generators and let them create my resources and actions for each
  4. Fill all gaps with actual implementation details
  5. Profit?

Am I making sense here, or did I fundamentally misunderstand what codegen in Ash does and looks like?

First 2 of 2 Posts Switch mode

zachdaniel

zachdaniel

Creator of Ash

Something like this is definitely possible. It is a big effort, and hard to say if it’s a good idea or not, I imagine it depends a lot on your domains. One difficulty may be the fact that Ash codegen tasks that you can use with igniter are not comprehensive by any means. They are made to produce useful starter points.

However, there are utilities you can all, like Ash.Resource.Igniter.add_new_action etc. to iteratively build up a resource, but those have basically been added over time as I’ve needed them.

The biggest challenge you may face realistically is that ash_json_api is primarily designed to help users create new JSON:API spec-compliant APIs. It is not necessarily designed to make building an API to an arbitrarily structured spec. You can absolutely write arbitrary API endpoints, generally by using generic actions, but you do end up hand-rolling some logic yourself if you do that.

Something worth pointing out is that if there is “just a handful of main routes”, you may not need to bother w/ all the fancy magic.

Not really a cohesive answer for you, but maybe some food for thought :laughing: Selfishly I love the idea of having something designed to reverse engineer API endpoints into an equivalent-ish internal resource structure and then allowing users to write in their own app logic. Sounds like a useful tool :smile:

Gonza

Gonza OP

Thanks! Yes, the old code looks standard-ish, but that’s obviously not the same as spec-compliant.
Still, now that I know it’s not a completely crazy idea, I might give it a try, even if just to learn how to work with generators. Thanks again!

— All posts loaded —

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement