loading

Roadmap to building your first AdonisJs web application

September 11, 20201 min read

Roadmap to building your first AdonisJs web application

AdonisJs is a Node.js web framework with a breath of fresh air and a drizzle of elegant syntax on top of it. It helps you write test-driven web applications easily. Learning Adonisjs as Nodejs/Laravel developer is quite easy because the flow is very similar.


Adonisjs core features

  1. Routing
  2. Middleware
  3. Controllers
  4. Request and Validators
  5. Response
  6. View
  7. Session
  8. Logger
  9. Events
  10. File upload
  11. Mails
  12. Database query and Lucid ORM
  13. Migration, seeders, and factories.
  14. Built-in JWT (JavaScript Web Token).
  15. CORS.
  16. CSRF Protection.
  17. TDD. (Feature and Unit test).
  18. Websocket.


Basic requirements

  1. Install Nodejs on your machine
  2. npm support
  3. Git bash


Installation of Adonisjs

Installation via CLI

AdonisJs CLI is a command-line tool to help you install AdonisJs.

Install it globally via npm like so:

> npm i -g @adonisjs/cli


For example, to create a new application called blog, simply:

> adonis new blog


Adonis also comes with a feature to create an API only application just like Express/Lumen

For example, to create a new application called blog, simply:

> adonis new blog --api-only



After crafting your application you can cd into the blog, to start your application in a development environment.

> npm install

> adonis serve --dev


It's serving your adonis application based on the port defined in your .env



Basic commands to use in your Adonis application

Start server

> adonis serve --dev


New application

> adonis new blog

> adonis new blog --api-only

> adonis new blog --slim


Make controller

> adonis make:controller User


Make model

> adonis make:model User


Make migration

> adonis make:migration User


Make validator

> adonis make:validator LoginRequest


Make command

> adonis make:command SetupAdmin


Make middleware

> adonis make:middleware isAdmin


Make exceptions

> adonis make:exceptions PaymentError


Make test

> adonis make:test AuthTest


Directory structure

  1. app: controllers, middleware, commands, models, exceptions, validator. etc.
  2. config: it holds different configuration files.
  3. database: migration, factory, seeder etc.
  4. public: it is used to serve the static assets of the site over HTTP.
  5. resources: it holds the views etc.
  6. start: it holds the route.js, kernel.js, app.js.
  7. test: it holds the feature and unit test
  8. ace
  9. package.json
  10. server.js

You can also consult their documentation for more info: https://adonisjs.com/docs/4.1/installation


Benart Share: