adonis-api-skeleton
adonis-api-skeleton copied to clipboard
Awesome AdonisJS boilerplate to create APIs using a DDD based architecture
AdonisJS API Skeleton
Awesome AdonisJS boilerplate to create APIs using a DDD based architecture
If you never worked with AdonisJS
before, please give a look in its docs first
How this architecture works
The major changes were made in the app
folder, so the files in bootstrap
, 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 folders you will be working with will be: Domains
and Modules
folders. Below I will talk a little about the folders inside app
:
-
Core:
These are helper files that I created to make things simpler when working with this boilerplate, most likely that you don't need to change nothing here. -
Domains:
Here you will create the domains of your application, each domain will have one or more:models
,repositories
,resources (like messages)
,validators
. Here you will put only domains that can be used and shared by yourModules
. -
Modules:
Here you will create the modules of your application, think in each module as anmicro service
, they're independent and can use one or manyDomains
. Each module needs to define their ownroutes
and will have one or more:controllers
,resources (like messages)
,services
. -
Providers:
Here you will find three files...-
channels.js:
File used to defineWebsocket channels
that your application can use -
events.js:
File used to defineEvents
that your application will run -
routes.js:
File used to define theRoutes
of your application, you only need to create an array with the modules you want to be loaded in your application.
-
-
Support:
Here you can put helper files that can be used by any of yourModules
andDomains
.
How to use
-
Clone this repo and enter it
-
Install the dependencies
yarn
- Copy the
.env.example
file to.env
file
cp .env.example .env
- Generate the application key
./ace key:generate
- Run the migrations
./ace migration:run
- Run the seeds
./ace db:seed
Commands available
- To run the lint use
yarn lint
- To run the app in development mode use
yarn serve:dev
- To run the app in production mode use
yarn serve
Things that needs to be done
This boilerplate was made only for an example, so there are some things (important things) that still needs to be done like: tests
, enhance the validation method, etc. Feel free to fork this repo and send some Pull Requests to help!!!
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/WendellAdriel/adonis-api-skeleton/. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.