Skip to content

API: The Koa.js App & Routing

Jake Lee Kennedy edited this page Nov 2, 2019 · 1 revision

The main entry point is index.js this just sets up the app and environment and starts the koa server.

The server.js is where most of the koa.js set up lies.

The middleware is effectively loaded backwards, so the first middleware will run last. The order at time of writing is

  • Error Handler
  • Commandline logger
  • Body Parser (parses JSON)
  • Authentication, add user to the session if an authorization token is present
  • Routes are Loaded

Routes

koa-router is used to create routes for urls/endpoints.

Each CRUD endpoint must have GET (Many), GET (Single), POST, PUT and DELETE methods implemented and tested.

Clone this wiki locally