About Architecture - ZetaRet/protoss-nodejs-basic GitHub Wiki

About Architecture

Not Favored cases

Typing function as var, const or let:

var myFuncName = function () {}
const myAsyncFunc = async () => {}

Self calling functions without living somewhere in the module, and without option to export:

(async () => {
//here we init the application and await first stuff and connections
})()

Implementing the route and endpoints

The use of classes, OOP and design patterns are favoured relying primarily on Router objects, and its implemented extends, working with the chosen server itself, and passing the function callbacks to the route via a well-designed api architecture usually of APIController and DataService classes on the side to deal with many tasks as database connectivity, 3rd party services and formal async/await implementation of the api method per route in the controller.

CRUD operations are essential part of the api management and non-supported request methods use the additional header REQUEST_METHOD to mimic and override behaviour.

Asynchronous pipeline

The synchronicity starts by pushing forward the pipeline, reading the request by the creation of IncomingMessage or corresponding object based on chosen server, processing of data and headers, request middleware, processing the request body structure, parsing content based on configuration and type of content, additional middleware, router callback and elevation of path events, and ending the response by various designs of architecture, including automated json, awaiting promised data by asynchronous data methods and processing of the final response middleware before writing and ending the response object. Pretty arbitrary control flow of events.