AdonisJS: Simple API Cheatsheet
A cheatsheet to help you as you build a simple API using AdonisJS framework for NodeJS.
- AdonisJS Documentation
- AdonisJS CLI Commands
- Knex ORM for NodeJS
- API Primer
- MySQL Workbench
- http Status Codes
My Contact Info
- Twitter: @patrickodacre
- Website: BuildtoLearn.io
- Customers -- name, description
- Projects -- name, description, customer_id
- Tasks -- name, description, project_id
These mistakes are a common source for my bugs:
- forgetting the 'await' keyword
- creating migrations in the wrong order
Understanding Models and the Query Builder
- Lucid's Model Class path to file: /node_modules/@adonisjs/lucid/src/Lucid/Model/index.js
- Lucid Documentation
- Query Builder Documentation
- Soft deletes (mentioned in the video on migrations)
Suggestions for More Practice
- Practice using migrations to add / delete tables and columns after you've interacted with the database a while.
- Can you use seeders to populate new columns added to an existing customers table or projects table?
- What's another way to handle the routing so you don't have to write GET, POST, etc. individually? hint: Watch out on the delete() method!
- How would you use the query builder to JOIN tasks to a project you want to GET using the show() method?
- How would you use Lucid to define the relationship between Projects and Tasks so you can load Projects WITH tasks?
- How can you implement basic authentication?