December release - 2020

This release has been mainly focused on fixing bugs and making subtle improvements to the existing packages and API.

Highlights

Upgrading dependencies

Make sure you update all the @adonisjs/* packages to their latest alpha releases. For example:

npm i @adonisjs/[email protected] @adonisjs/[email protected] <other-packages>

There are no breaking changes in this release, so expect everything to work smoothly.

Auth tokens Redis provider

We have added another provider for storing api tokens to Redis. This is how we expect you to choose between the database and the redis provider.

Usually, the personal access tokens are long-lived and are not generated in bulk in a short time and hence SQL database storage is perfect for them.

In this scenario, tokens are generated in bulk and will be expired after some duration. Redis is a perfect storage option here since it auto cleans the expired key-value pairs

The configuration for the tokens is defined within the config/auth file.

[codegroup]

{
tokenProvider: {
driver: 'database',
table: 'api_tokens',
}
}
{
tokenProvider: {
driver: 'redis',
connection: 'local',
}
}

[/codegroup]

When using the Redis driver, you have to define the connection inside the config/redis file and reference the connection name from the tokenProvider.connection property.

Mailer classes

You can now configure/send emails by defining them inside a dedicated mailer class. This will clean up your controllers as you can remove all the inline Mail.send calls. Also, the self-contained mailer classes are easier to unit test.

Begin by upgrading the @adonisjs/mail package.

npm i @adonisjs/[email protected]

[note] The following steps are only required when upgrading an existing application. For new applications, the command will be added automatically on the node ace invoke call. [/note]

Next, open the .adonisrc.json file and register the mail package to the array of commands.

{
"commands": [
// ...
"@adonisjs/mail/build/commands"
]
}

Finally, run the following ace command to generate a manifest file of all the commands available in your app.

node ace generate:manifest

After this, you can create mailer classes by running the node ace make:mailer command. Also make sure to read the docs as well.

New syntax for Edge components

With the latest release of the @adonisjs/view package, we will recursively scan the resources/views/components directory for .edge templates and make them available as tags. For example:

Instead of writing the following

@component('components/modal', { title: 'Want to continue?' })
@endcomponent

You can now write

@modal({ title: 'Want to continue?' })
@end

In this approach, the file name becomes the tag name. The filenames using _ or - will be converted to camelCase.

The components inside nested directories are accessible using the dot . separator.

Other improvements

Bug fixes