- Unit Testing: Write unit tests for your application logic using AdonisJS’s built-in testing utilities.
- Integration Testing: Test how different parts of your application work together, including routes and controllers.
Category: 07. Adonis Js
https://avatars.githubusercontent.com/u/13810373?s=280&v=4
-
Testing
-
Caching
- Caching Strategies: Improve performance by caching frequently accessed data. AdonisJS supports various caching drivers like Redis and Memcached.
- Configuration: Configure caching settings in
config/cache.tsorconfig/cache.js.
-
Email and Notifications
- Sending Emails: Configure the mail provider and use the
adonis-mailpackage to send emails. - Notifications: Implement a notification system to inform users of important events or updates.
- Sending Emails: Configure the mail provider and use the
-
Validations
- Validation Rules: Use the built-in validation rules to ensure data integrity. AdonisJS provides a comprehensive set of rules and error messages.
- Custom Validation: Create custom validation rules if the built-in ones don’t meet your needs.
-
Authentication and Authorization
- Authentication: AdonisJS includes built-in support for user authentication. Use the
adonis authpackage to set up login and registration functionality. - Authorization: Implement role-based access control (RBAC) to manage user permissions and access to various parts of your application.
- Authentication: AdonisJS includes built-in support for user authentication. Use the
-
ORM (Object-Relational Mapping)
- Lucid ORM: Provides a powerful way to interact with the database using models. It supports relationships, eager loading, and more.
- Defining Models: Create models using the
adonis make:modelcommand and define relationships in your model classes.
-
Middleware
- Definition: Middleware functions execute during the request-response cycle, allowing you to handle tasks like authentication, logging, and more.
- Creating Middleware: Use the
adonis make:middlewarecommand to create custom middleware. Register middleware instart/kernel.tsorstart/kernel.js.
-
Routing
- Basic Routing: Define routes in
start/routes.tsorstart/routes.js. AdonisJS provides methods for handling HTTP requests (GET, POST, PUT, DELETE). - Named Routes: Simplify URL generation and management by naming your routes.
- Basic Routing: Define routes in
-
MVC Architecture
- Models: Define the data structure and interact with the database. AdonisJS uses Lucid ORM for database operations.
- Views: Handle the presentation layer. AdonisJS supports the Edge templating engine for rendering views.
- Controllers: Manage the application logic and interact with models and views.
-
Installation and Setup
- Prerequisites: Ensure you have Node.js and npm (Node Package Manager) installed on your machine.
- Installation: You can install AdonisJS globally using npm. The basic command is
npm i -g @adonisjs/cli. - Creating a New Project: Use
adonis new project-nameto generate a new AdonisJS project. This command sets up a new directory with a project scaffold and installs the necessary dependencies.