Adonis API Application is the boilerplate for creating an API server in AdonisJs which implemented Domain Driven Design Pattern. It comes pre-configured with.
- Bodyparser
- Authentication
- CORS
- Lucid ORM
- Migrations and seeds
The major changes were made in the app folder, so the files in bootstrap (start), config and database works the same way as described in the AdonisJS docs, there were only few changes in these folders, so you don't need to worry too much about them.
This boilerplate uses a DDD based architecture, so the main folder will be working with: Domains and Modules folders.
Domains and Modules directory is automatically created when you run:
adonis make:module [MODULE_NAME]this command will generate themodule.adonis make:domain [DOMAIN_NAME]this command will generate thedomain.
Here's project structure in AdonisJs API Skeleton.
/
├── app/
├── Core/
├── Commands/
├── Generators/
├── BaseCommand.js
└── ModuleCommand.js
└── Templates/
├── Contracts/
├── Controller.js
├── Repository.js
└── Service.js
└── Http/
├── kernel.js
└── router.js
├── Domains/
└── .../
├── Models/
├── Repositories/
└── Validators/
├── Middleware/
├── Modules/
└── .../
├── Http/
├── Controllers/
└── Routing/
├── Resources/
└── Services/
└── Providers/
└── routes.js
├── bootstrap/
├── ace.js
├── app.js
└── http.js
├── config/
├── app.js
├── auth.js
├── bodyParser.js
├── cors.js
├── database.js
└── hash.js
├── database/
├── migrations/
├── seeds/
└── factory.js
├── ace
├── package.json
└── server.js/
The app directory is the home of your application logic.
It’s autoloaded under the namespace App.
The bootstrap directory is used to store files that are loaded at the boot of your application.
The config directory is used to define the configuration of your application.
AdonisJs ships with a number of config files, but feel free to create your own.
Read more about configuration.
The database directory is used to store all database related files.
The app/Core are helper files that created to make things simpler when working with this boilerplate, most likely that you don't need to change nothing here.
The app/Domains are the domain of your application, each domain will have one or more:
modelsrepositoriesvalidators
Here you will put only domains that can be used and shared by your Modules.
The app/Middleware directory is used to store all your middleware. This directory is automatically created when you run adonis make:middleware <name>.
The app/Modules are the module of your application, think in each module as an microservices, they are independent and can use one or many Domains. Each module needs to define their own routes and will be have one or more:
controllersresourcesservices
The app/Providers directory is used to store all file like:
channels: used to defineWebsocket channelsthat your application can use.events: used to defineEventthat your application will run.routes: used to defineRoutesof your application, you only need to create an array with themodulesyou want to be loaded in your application.
- Clone this repository
git clone https://gitlab.com/f.widjaya20/adonis-api-skeleton.git - Change origin url to your own repository with
git remote - Install dependencies with
npm installoryarn install - Serve project :
adonis serve - Have fun!
We would love for you to contribute to this repo and help make it even better than it is today! Build your code and submit your Pull Request.
Thankyou!