Setup Node.js Express application with Typescript, Router Controller, TypeDI and TypeORM - Part 1
This post will not cover what node.js is. There are an infinite number of posts where it is described what node.js is. As the official site says:
Why use Node.js ?
These are some of the advantages of using node.js:
- Non-blocking Input/Output and asynchronous request handling
- Lightweight and small footprint: an advantage for the microservices architecture that allows orchestrators to create new service instances when requests increase
- A huge ecosystem of libraries for every type of scenario thanks to npm
Some of the advantages listed above can also be seen as disadvantages:
- Asynchronous programming model which is more difficult in comparison to the linear blocking I/O programming
- Performance bottlenecks on CPU intensive operation
- Callback hell: like the homonymous site reports
How can we get around these obstacles?
Async/Await: which simplify nested callbacks
Routing Controllers: use libraries like routing-controllers to bind requests to methods of classes acting as controllers instead of inline plain functions
ORM: using libraries like TypeORM you will be able to write queries using the object-oriented paradigm of your programming language