Hey I come from Ruby world and I would say that there are some well-known gems like Devise, ActiveModelSerializer, Sidekiq, etc, that most of Rails projects are using. What I mean is that when I need to solve A I can just reach for some well known well-used gem A.
And how does it look like in Phoenix? From what I see a lot of packages are not actively maintained and many lack support for Phoenix 1.4, which shouldn’t be a big deal if a package is Phoenix oriented. I spend a lot of time looking for a correct package and many times I am disappointed.
What are your thoughts? I would like to build Saas serverside rendered, need a login, some permissions probably, background jobs, maybe some statistics, activities feed…
Does anyone feel similar? Or do you just build everything yourself? Maybe you miss something from other ecosystems?
I asked this on reddit, but I haven’t received any meaningful answer, so maybe here I will have better luck.
Just please don’t tell me not to use many packages, because they are bad or wrong. I understand that point of view, but I don’t have a team of 10 people to implement every necessary feature, it’s just me.
Short answer: if you can implement such feature on your own in reasonable time, then do not use library.
- If you can, use outside provider like OAuth from Google/FB/Twitter/etc. This will save you a lot pain in user management
- If you cannot use the above, then implement it on your own using Comeonin with bcrypt or Argon2 (I would use that order, but some people may disagree)
- Authorisation (permissions) - I would use functions, you know, that thing where you pass 2 arguments (user and resource) and return
false. Nothing fancy needed, especially as pattern matching will do 99% of the work.
- Background jobs - for simple things -
GenServer, for more complicated things -
GenServer + DB queue
- Statistics (if you mean in app stats) - SQL queries
- Metrics - there I would 100% go with a library, just go and pick something (my personal choice is OpenCensus but I am biased here)
Hey, thanks a lot. I am curious, what do you mean by GenServe + DB? Do you have any example?
There are a few packages that implement job queues over a DB table.
EctoJob is one I maintain that is little more than GenStage producer and ConsumerSupervisor triggered by Postgrex.Notifications.
Elixir makes building these things really simple and fun
The packages I use most often across all my projects are(in no order):
absinthe + related
For auth if its b2c I’ll reach for uberauth and social logins but generally I prefer just a self rolled auth system using comeonin permissions self rolled too. I never really liked working with stuff like cancan.
Background jobs I just use separate processes or genservers.
I felt similarly when I first started out with Phoenix. It seems a lot of the earlier elixir libraries are ports from popular ruby libraries, made by developers who just started out with elixir. It’s constantly improving though, and there are some great libraries for what you need.
For background jobs, I really like honeydew. We’re planning to use it in production soon. For user authentication, I’ve written Pow and currently run it in two production apps. For permissions you should build it yourself, it’s super simple with a plug module.
I don’t like to waste too much time with my (tiny) team on things that isn’t essential to our business, so I get where you are coming from. It took some time to switch from rails mindset to phoenix/elixir, but it was definitely worth it for us. Our development is running much smoother now, and after learning the a-z with our first app, it has been an incredibly easy process to build new apps, and we haven’t felt much was lacking in the ecosystem.