Nodejs
  • December 21, 2021
  • Enes Çelik

What is Nodejs?

As it is known, the Javascript programming language used to be a client-side language. When Chrome V8 was launched, we were able to use the Javascript language on the server-side as well. That's why the Chrome V8 Engine, which allows us to run the Javascript language on the server side, is named Node.js. Node.js is a dynamic and fast language that is based on Javascript and works on the server side.

History of Node.js

It was developed by Ryan Dahl in 2009 by making necessary additions to the V8 Javascript engine so that the Google Browser can run Javascript codes. The reason why Node.js is popular is that besides its performance and speed, Javascript commands are flexible, non-blocking and event-based, and there is no need for additional web server (Nginx, ISP, Apache, HTTP, etc.) such as other server-side programming languages.

The Differance

In other programming languages that work server-side, when the user makes any request, only that request is answered and other requests are queued. A request taking a long time can affect other users.

Since Node.js does not block and process commands, it does not slow down the system with long-lasting commands and also responds to other users. The best example of this can be called the food ordering system. In normal server-based programming languages, when a meal is ordered, customers standing in other rows wait for the order to be prepared. When a food order arrives, Node.js notifies the chef of the order and takes notes, and then takes the next customer's order.

Whichever of the given food orders is prepared first, responds to that food order. Therefore, the customer does not wait long in line for his meal. Thanks to this structure, real-time applications such as game systems and instant messaging can be made easily and with less cost.

Express.js

Express.js package is a Node.js based web application server framework Building a robust API is quick and easy, thanks to the unlimited HTTP layers and utilities that Express.js offers. Express.js is also one of the components of the MEAN software bundle. MEAN (MongoDB, Express.js, Angular.js, and Node.JS) is a free and open source software bundle used to develop dynamic websites and web applications. Also, Express.js is part of many frameworks besides MEAN.

TypeScript

Node.js, which is heavily used in web applications, has been used frequently in server-side applications with JavaScript, desktop applications with Electron.js, and hybrid mobile application development thanks to various libraries and has grown to be predictable. JavaScript had some structural shortcomings because it was not intended for large-scale applications. The type checking provided by object-oriented languages was difficult. TypeScript has emerged as a programming language designed to address these shortcomings and to use JavaScript better and more effectively in large projects.

TypeScript is defined as JavaScript for application-scale development. TypeScript is strongly-typed, a compilable open source and object-oriented programming language. It was designed by Anders Hejlsberg, a Microsoft employee and designer of the C# language. Its first version was published in 2012.

We can define TypeScript both as a set of tools and as a language. It is used to write JavaScript programs that can run in a server or client environment. It can be defined as a superset that includes all the features of JavaScript with additional features added. Increases efficiency in large and complex coding projects.

What is ORM (Object Relational Mapping)?

SQL language is used to perform a transaction in the database. Sometimes we have to write a long SQL query even for simple operations. At this point, ORM technology makes database operations that can be done while working with any platform almost independent from SQL. This is simply the logic of the ORM. We create objects and functions to represent each structure in the database with the OOP / Object Oriented Programming language that we use while developing the project, and we use these objects and functions while performing the operation.

Simpler object insertion:

With SQL: sql With ORM: orm

In short, ORM technology saves you from writing long SQL codes for simple operations.

What is TypeORM?

TypeORM is an ORM technology that can run on platforms such as browsers, React Native, NodeJS and can be used with JavaScript, TypeScript. It has two different approaches, Data Mapper and Active Record. While Active Record is a bit plain and simple; Data Mapper is included in the repository. That's why Active Record is used for small scale applications. For applications with large scale, it is more appropriate to say that Data Mapper is used. However, it can be said that there is not a huge selection difference between them.