Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
A.k.a trying out NodeJs’s own Laravel-like framework
If you’re a beginner to the @nodejs world and you feel overwhelmed by all the packages you need to install and configure to build your first simple app (routing, parsing, mailer, orm, and a big etc) don’t worry, @adonisframework is here for you.Gabriel Lecointere
Since I discovered AdonisJs, I was obsessed with the idea of building something with it. Now that I have some free time, It’s time to build a job board!
The value proposition of the framework is exactly what the NodeJs ecosystem lacks right now, in my opinion: A very opinionated and productivity-oriented monolithic framework. Adonis is pretty much a Laravel/Rails clone built on top of NodeJs
If you are not familiar with Laravel/Rails: Basically, AdonisJs takes care of handling Authentication, routing, mailing, database/ORM configuration for you with built-in modules, so you can just focus on your app logic
I’ve grown really bored of rolling out my own auth system, db config, model engine ect.. every single time I was building a new project with Express/Koa. The built-in auth module of AdonisJs was already enough to convince me.
AdonisJs : the good parts
So what’s so great about AdonisJs?
First, the typical Adonis app has a strict MVC structure, so you don’t waste time figuring out how you should structure your app like with a minimalistic framework ( ex. Express/Koa)
AdonisJs command line tools (CLI) is really useful, you can generate all the scaffolding rather then having to write the same code again and again
The CLI is so powerful that you don’t even really have to write that much code to start with, the command line tools can generate a lot on their own (a lot like Rails “generate scaffold” CLI command) :
In order to build the job board, its all boils down to a series of CLI commands:
#Install Adonis CLInpm i --global @adonisjs/cli
# Create the projectadonis new job-board# Install the databaseadonis install sqlite3
# Create the "Jobs" SQL tableadonis make:migration jobs // pick "Choose an action" -> "Create table"adonis migration:run
#Create the related JS Model and Controlleradonis make:model Jobadonis make:controller JobController // pick "HTTP controller"
And voilà, you’ve generated the app structure:
- The “Job” database table- The model file (/models/Job.js)- The related HTTP controller (there is a support for socket-based controller)
What about the user table, model and authentication methods?
Well, it’s already been taken care of, when you used the adonis new job-board Command, all the user related scaffolding have been generated!No more pulling your hairs off, or battling with Passport.js documentation during 2 days
What about Facebook/Twitter/Instagram/linkedIn authentication?
There is a drop-in AdonisJs module for that too, of course!
If you have a CRUD generator, and the authentication has already been generated for you, what’s left to build for AdonisJobs?
I only created the forms, validators and a basic UI, and went straight to deploy my small app
How long did it take me to build the job board and deploy with AdonisJs?
4 hours. it would have taken me way longer with my usual Express/mongoose/Passport setup
What about security?
There is a module, shield, and a guide
Can you just build an API with AdonisJs, and not a full MVC monolith?
Sure, just use adonis new -api-only job-board
Finally, as a last good part, AdonisJs has native support for Async/Await, and much more modern Javascript features, unlike Express current version
AdonisJs: The bad parts
The main critics against the framework relies in the fact that AdonisJs introduce a lot of it’s own modules :
As an example, rather then using a pretty standard templating engine like EJS or Handlebars, AdonisJs use it’s own Edge templating engine, which syntax isn’t too far from Handlebars. I’ve seen several people on Reddit /r/webdev or /r/node being upset at the fact that the framework isn’t using mainstream Node modules
It’s the same for the ORM, called Lucid, the routing and pretty much everything within the framework
I do not agree with these critics, IMO, in order to build a monolithic framework, you need to have a perfect control on every single part of it, which means creating you own building bocks for each aspect of the framework
TL;DR :
I’ve built AdonisJobs with AdonisJs to try out the framework, in conclusion:
- In my opinion, A beginner-friendly, highly opinionated framework with a gentle learning curve like AdonisJs was much needed in the Node ecosystem
- If you’re a Node developer and have been looking for a productivity-oriented, Rails-like/Laravel-like framework, or if you are bored of setting up together the same Express/Mongoose/Passport boilerplate, this might be the perfect fit for you!
Notes:
- I’m planning on doing the same review with NestJs, you can follow me if you’re interested in the result
- In order to build my job board, I followed the Adonis 4 crash course by Gary Simon
My takeaways from building a job board with AdonisJs 4 was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.