Clock-In/Out System Part 4: Basic Back End (III) — AppModule
A NestJS + Angular tutorial
This piece is part of a series in which I describe a clock-in/out system. If you want to learn more, you can read the following:
- Clock-In/Out System Part 1: Diagram
- Clock-In/Out System Part 2: Basic Back End — AuthModule
- Clock-In/Out System Part 3: Basic Back End — UsersModule
- Clock-In/Out System Part 4: Basic Back End — AppModule
- Clock-In/Out System Part 5: Seed Database and Migration Data
- Clock-In/Out System Part 6: Basic Front End
- Clock-In/Out System Part 7: Deploy Back End (NestJS) Using Docker/Docker-Compose
- Clock-In/Out System Part 8: Deploy Front End (Angular 6+) Using Environments
- Clock-In/Out System Part 9: Back-End Testing — Unit Testing of Services
- Clock-In/Out System Part 10: Back-End Testing — Unit Testing of Controllers
- Clock-In/Out System Part 11: Back-End Testing — E2E Testing
- Clock-In/Out System Part 12: Front-End Testing — Unit Testing
- Clock-In/Out System Part 13: Front-End Testing — Integration Testing
In the previous piece, I presented the module
UserModule, used to manage information about the user. I recommend that you read the first piece before this one so that you understand the whole system.
This piece will present the
AppModule which is used to manage the request of the user from an Angular front end. This module only has a service, controller, and module.
AppService injects the two services
AuthService from the modules
AuthModule. It is used as a wrapper that uses both services.
The first step is to show you the
You can see that this module imports
UsersModule. This is important because
The next step is to develop the controller, which contains two routes associated to clock-in and clock-out.
They invoke the
AppService (which will invoke
AuthService) and one route associate to get the list of users currently working and the timestamp from the server (to get it in near real-time, which will invoke
The final step is to develop the
AppService, which uses the two previously mentioned services.
In this piece, I’ve explained my
AppModule. It is quite simple as I’m using clean code in my coding.
This module is used to communicate client-side (Angular) and server-side. It imports
UsersModule and exports their services. These services are used to save information about the clock-in/out and to get all users that are currently working.
At the moment, we’ve developed a basic back end with three modules and different endpoints.
In the next piece about the back end, we will explain the seed of the database and testing. The pieces after that will explain how to build a basic front end using Angular and RxJS.