v2 launch promo! Get a one-off 50% discount on PRO yearly using V2LAUNCHPROMO. Get started

Creating An AdonisJS 5 Application

In this lesson, we see how to create our first AdonisJS 5 application using create-adonis-ts-app.

Chimezie Enyinnaya

Hi, I'm Chimezie Enyinnaya, your teacher.

I’m a self-taught software developer based in Lagos, Nigeria, with over 8 years of experience. In the last couple of years, I've been doing more teaching because I enjoy sharing my knowledge so that others can benefit from it. Come along as I teach you all I know about AdonisJS, Node.js, and JavaScript at large!

AdonisJS 5 From Scratch

1hr 51mins
31 lessons
Beginner

Getting Started

1m 44s

We start with a brief introduction to AdonisJS and the format of the course.

In this lesson, we set up our computer by installing the necessary requirements for AdonisJS 5 such as Node.js >= 12 and NPM >= 6.

In this lesson, we see how to create our first AdonisJS 5 application using create-adonis-ts-app.

Ace is a command line tool for executing AdonisJS commands. In this lesson, we take a look at how to make use of it to run commands.

Since TypeScript cannot be executed directly by Node.js, we need to compile it to JavaScript, which Node.js can then execute. Let’s take a moment to understand what happens when we run serve command.

In this lesson, we go over the directory structure of an AdonisJS 5 application.

Routing

4m 47s

Routes serve as entry points to an AdonisJS application. In this lesson, we cover how to create routes.

3m 8s

We have seen how to create static routes, what if we want to create dynamic routes? In this lesson, we cover how to do just that.

While it’s totally fine to use inline handler, but this can make routes.ts to become messy. Hence, it is recommended to move route handling implementation out of the routes file to a dedicated file called controller.

5m 15s

Naming routes can save time or help prevent broken links if we ever change the URLs later on. In the lesson, we cover that named routes are and how to use them.

Views

Edge is AdonisJS templating engine, and in this lesson, we cover the basics of the templating engine.

Ideally, we will need to pass data to our views, be it from the database, the HTTP context, or even computational data. Let’s see how we can do that.

Typically, we would want to have a kind master HTML layout, which other pages can extend instead of having to repeat the same HTML boilerplate across all pages. Luckily for us, Edge has support for layouts.

In this lesson, we cover how to extend a layout we created in the last lesson.

Working With Database

Unless we are building a static site, our application will definitely need some database interactions. In this lesson, we set up a database for our application.

2m 47s

We can think of migrations as some kind of version control for database schema. We cover what migrations are and how to create our first migration.

2m 17s

Lucid is AdonisJS ORM and it represents the M in AdonisJS MVC structure. In this lesson, we cover what Lucid is and how to create a Lucid model.

Working With Forms

8m 3s

In this lesson, we start off by covering how to secure our application against CSRF when working with forms and then move on to create tasks.

As good developers that we are, we know too well not to trust user-submitted data. So in this lesson, we cover how to validate form data to make sure users fill our form correctly.

2m 30s

It will be nice to have a kind of feedback that a task was created successfully. We cover how to do just that with flash message.

2m 37s

In this lesson, we look at how to retrieve and display all the tasks that have been created.

7m 24s

In this lesson, we cover how to mark a task as completed as well as mark a task as uncompleted.

3m 25s

In this lesson, we cover how to delete tasks.

Authentication

AdonisJS provides a seamless way to add authentication to our application, but we need to first install and set up the Auth package.

In this lesson, we cover how to allow users to an create account in our application.

3m 10s

In this lesson, we add the ability for users to log out of their account.

4m 56s

Upon registering, users are logged in automatically. In this lesson, we cover how to allow users to manually logging in to their account.

In this lesson, we cover how to secure and enhance our application using middleware.

Lucid Relationships

With the authentication system in place, let's add a way to associate tasks with users.

In this lesson, we cover how to make use of the defined relationship to create user's tasks.

Instead of fetching and displaying all created tasks, let’s fetch and display only the tasks for the currently authenticated user.

Source code
Lesson video (SD)
Lesson video (HD)