paint-brush
My takeaways from building a job board with AdonisJs 4by@MaxenceCornet
7,746 reads
7,746 reads

My takeaways from building a job board with AdonisJs 4

by Maxence CornetOctober 4th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

A.k.a trying out NodeJs’s own Laravel-like framework

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - My takeaways from building a job board with AdonisJs 4
Maxence Cornet HackerNoon profile picture

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 app structure

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:

  • Show and discover projects built with AdonisJs on madewithadonisjs.com
  • 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