Adonis

Adonis – Power MVC Framework with Authentication and Bootstrap

Node.js Framework Adonis as MVC

Node.js is a common language based on JavaScript. It is well know and popular since with the help of V8 JavaScript can be executed on server side. In the past JavaScript was used in browsers to enrich the client side. This is still the case but still the entrance barrier is quiet easy. This is really good to get more people on the light (development) side of live. But the downside is that JavaScript comes with the feeling it is often not well structured and developed. The same is happening on server side implementation since it is really easy to write dirty code. As well Node.js on server side is quiet new and in comparison other languages like Ruby or Java have a longer lifetime to develop MVC Webframeworks.

That’s why more and more MVC Frameworks taking the chance to proof Node.js a comparison. Adonis not only have a name which leads to the assumption of winning a comparison it also has some nice features why we took the chance to work with.

Installation

See http://adonisjs.com/ for more documentation

$ npm install -g adonis-cli
$ adonis new exampleAdonisProject
$ cd exampleAdonisProject
$ npm start

Alternative you can check out our Adonis template which contains authentication and Bootstrap + LESS + Gulp as well: https://github.com/unicorn-it/adonis-template

$ git clone https://github.com/unicorn-it/adonis-template
$ cd adonis-template
$ npm install
$ bower install
$ gulp

 

Adonis commes with ES6 (ECMAScript 2015) support

We used koa framework in past projects to develop based on our own MVC structure Node.js web applications (https://github.com/unicorn-it/koa-scaffold). We prefered koa over express since it supported ES6 too. We love the flow control of generators. That’s why we love Adonis even more.

Adonis uses Babel to complete the journey to ES6

Adonis is not only using ES6 language support which is included in Node.js so far it also uses Babel to support the hole ES6 language. This is why the code looks even more expressive and meaningful.

class HomeController {
  * index(request, response) {
    const view = yield response.view(‚index‘);
  response.send(view)
  }
}
module.exports = HomeController;

Awesome routing in Adonis

In Adonis we directly loved the routing. In our own MVC we added the routing in the main JavaScript file. So the idea is the same. Having one place where the routing deifinition is placed. This is done in Adonis by defining in meaninful language the routing.

const Route = use(‚Route‘);

Route.get(‚/‘, ‚HomeController.index‘);

Route.get(‚/‘, ‚HomeController.secured‘).middlewares([‚auth‘]);

Adonis comes with nice templating

We used to prefere SWIG as a template engine for Node.js frameworks. Its easy, its next to the syntax of AngularJS and this helps a lot to get frontend developers into it. Adonis comes with a syntax which is next to SWIG. It is called Nunjucks which is inspired by Jinja and closed to SWIG. However it helps us a lot when dealing with html in Adonis.

Very nice MVC project structure

The folder structure of Adonis is really easy to understand. This helped us a lot to understand the structure and parts of the application. It will also help other developers figuring out where to make changes to get the expected result. So switching between projects will become more easy. They will directly find what they are looking for. See the example of our project,

Adonis project structure

What’s missing

But of course Adonis is not perfect and there are many parts missing. Especially for us when we are looking for a project setup to start from scratch really easy and fast. The documentation of Adonis is nice so far but its not easy to get an understanding of how to implement security in Adonis. As well as we love to work with bootstrap based on LESS files. Therefor we need to extend the basic Adonis installation. You can check out our repository and have a look for Adonis.

https://github.com/unicorn-it/adonis-template

Have fun while using Adonis – the powerpack

0 Kommentare

Dein Kommentar

An Diskussion beteiligen?
Hinterlasse uns Deinen Kommentar!

Schreibe einen Kommentar