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?

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:

2 Likes