Implementing the Service layer
Layered Architecture·2 min read·Jan 1, 2025
The Service layer is located between the Router layer and the Data Access layer.
It is completely agnostic from any transport mechanism such as HTTP or AMQP, which means that it can receive data from multiple sources and still process it effectively.
It contains the business logic of the application and is responsible for:
-
Performing application-specific tasks using the parsed and validated data sent by the Router layer according to the defined set of business rules (e.g. generating new session tokens, sending emails, and so on).
-
Calling the Data Access layer in the case it needs to communicate with an external component, such as a database.
Installing the required packages
Let's start by installing the following packages:
$ npm install --save bcrypt jsonwebtokenWhere:
-
bcryptis a library used to generate and compare hashes based on the Blowfish cipher.
Unlock the Build Layered Services in Node.js module
Learn how to build well-structured, easily maintainable, and resilient microservices with the three-layer architecture.
You get immediate access to:
- 10 focused lessons across the three-layered architecture
- 1 real-world commented, step-by-step project
- Ongoing updates to this bundle
- Lifetime access to this bundle