Skip to content

Instantly share code, notes, and snippets.

@patrickodacre
Last active April 1, 2024 12:19
Show Gist options
  • Star 44 You must be signed in to star a gist
  • Fork 60 You must be signed in to fork a gist
  • Save patrickodacre/31590fa7ef9983a94444fba90cc63ec3 to your computer and use it in GitHub Desktop.
Save patrickodacre/31590fa7ef9983a94444fba90cc63ec3 to your computer and use it in GitHub Desktop.

AdonisJS: Simple API Cheatsheet

A cheatsheet to help you as you build a simple API using AdonisJS framework for NodeJS.

Important Links

My Contact Info

Project Overview

  • Customers -- name, description
  • Projects -- name, description, customer_id
  • Tasks -- name, description, project_id

Common Mistakes

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

Further Study

Suggestions for More Practice

  1. Practice using migrations to add / delete tables and columns after you've interacted with the database a while.
  2. Can you use seeders to populate new columns added to an existing customers table or projects table?
  3. 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!
  4. How would you use the query builder to JOIN tasks to a project you want to GET using the show() method?
  5. How would you use Lucid to define the relationship between Projects and Tasks so you can load Projects WITH tasks?
  6. How can you implement basic authentication?
@AsadJivani
Copy link

API Primer URL is not working currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment