AdonisJs, a Nodejs Framework for Humans

I feel like home!

If you are a PHP developer and ever worked with Laravel you probably fell in love with it. Laravel is a super powerful and elegant framework. Makes your work easier and you can make really rapid softwares with it.

Ofcourse Laravel has it’s own issues, but we are not going to talk about it here.

I want to talk about a Nodejs framework; Adonisjs.

Adonisjs is a Nodejs framework, It is very beatifuly designed. I can say it is definetly Laravel in Nodejs. The stracture is nearly same so you can easily learn it. Like Laravel, you can make applications super rapidly, it contains nearly everything that you need.

You can find AdonisJs homepage here. Github repository is here. Lastest stable version of AdonisJs is 3.2, V4 is on the way!

You can watch a trailer about 4.0 pre-release

I want to show you similarities now.

├── app 
│ ├── Commands
│ ├── Http
│ ├── Listeners
│ ├── Model
├── bootstrap
├── config
├── database
│ ├── migrations
│ └── seeds
├── providers
├── public
├── resources
│ └── views
├── storage

directory structure of adonisjs


You can watch a trailer about AdonisJs routes.

the Router is identical with Laravel. You don’t really need AdonisJs documantation if you know Laravel.

const Route = use('Route')
Route.get('/', 'HomeController.index')

const Route = use('Route')  
Route.get('/', function * (request, response) {
response.send('This is the home page')

a Closure route example

Of course there are some limitations with Nodejs(for example lack of Reflection api) but they tried to overcome this problem in the best way they could.

* Create a new controller instance.
* @param UserRepository $users
* @return void
public function __construct(UserRepository $users)
$this->users = $users;

thanks to PHP’s Reflection api, Laravel can automatically inject our depencies but Javascript does not have such a thing, so you have to tell what you need.

static get inject () { 
return ['App/Model/User']

Powerful ORM

Laravel’s Elequent is one of most powerful orm of PHP. It makes your whole life easier.

Adonisjs has Lucid and it is powerful as Elequent,you can use migrations,seeds, factories and comes with very similar syntax.

use Illuminate\Database\Eloquent\Model;

class User extends Model
protected $table = 'users';

Lucid version;

const Lucid = use('Lucid')

class User extends Lucid {
static get table () {
return 'users'

aren’t they cool?

I’ve tried lucid with PostgreSql and Mysql and it worked very stable.

Simple Authentication

Every Web application deals with User Management and Authentication at some stage. AdonisJs Authentication provider is a fully featured system to authenticate HTTP requests using multiple authenticators. Using authenticators, you can build traditional session based login systems to secure REST API’s.

an example for session based authentication.

module.exports = {  
authenticator: 'session',
session: {
serializer: 'Lucid',
scheme: 'session',
model: 'App/Model/User',
uid: 'email',
password: 'password'

What about performance ?

I found this article about NodeJs performance benchmark.

As you can see Adonis is not fast as Express and that is not very suprising. Adonis gives you very powerful system and that comes with a cost.

Adonis teams says Adonis 4.0 will be thrice as fast as Adonis 3.2, so we are excitedly waiting for it.

Keep in mind; this results only made for ahello world application. The real time result will be diffrent.