Part 4. Clock-in/out System - Basic backend (III) - AppModule
Tags: javascript, typescript, node, nestjs
Published: 2019-03-06 12:51:27

---
title: Part 4. Clock-in/out System - Basic backend (III) - AppModule
published: true
tags: javascript, typescript, nodejs, nestjs
description: This post will presented the AppModule which is used to manage the request of the user from an Angular frontend. This module only have a service, controller and module. The AppService inject the two services 1. UserService and 2. AuthService from the modules UsersModule and AuthModule respectly. This service is used as a wrapper which use both services.
series: clock-in/out system
canonical_url: https://carloscaballero.io/part-4-clock-in-out-system-basic-backend-iii-appmodule/
cover_image: https://cdn-images-1.medium.com/max/1000/1*KhCkmbtORw2Ux3n5WCrtzA.png 
---
This post is part of a Series of post which I’m describing a clock-in/out system
if you want to read more you can read the following posts:


* [Part 1. Clock-in/out System: Diagram.](https://dev.to/carlillo/part-1-clock-inout-system---diagram-4kgj)
* [Part 2. Clock-in/out System: Basic backend — AuthModule.](https://dev.to/carlillo/part-2-clock-inout-system-basic-backend-i--authmodule-d2l)
* [Part 3. Clock-in/out System: Basic backend — UsersModule.](https://dev.to/carlillo/part-3-clock-inout-system---basic-backend-ii---usersmodule-5hf5)
* [Part 4. Clock-in/out System: Basic backend- AppModule.](https://dev.to/carlillo/part-4-clock-inout-system---basic-backend-iii---appmodule-5anb)
* [Part 5. Clock-in/out System: Seed Database and migration data](https://dev.to/carlillo/part-5-clock-inout-system-seed-database-and-migration-data-320m)
* [Part 6. Clock-in/out System: Basic frontend.](https://dev.to/carlillo/part-6-clock-inout-system-basic-frontend---angular-28pg)
* [Part 7. Clock-in/out System: Deploy backend (nestJS) using docker/docker-compose.](https://dev.to/carlillo/part-7-deploy-backend-nestjs-dockerdocker-compose-3cmb)
* [Part 8. Clock-in/out System: Deploy frontend (Angular 2+) using environments.](https://dev.to/carlillo/part-8-clock-in-out-system-deploy-frontend-angular-6-using-environments-nog)
* [Part 9. Testing: Backend Testing — Unit Testing - Services](https://dev.to/carlillo/part-9-clock-in-out-system-testing-backend-testing-3imk)
* [Part 10. Testing: Backend Testing — Unit Testing - Controllers](https://dev.to/carlillo/part-10-testing-backend-testing-unit-testing-controllers-573a)
* Part 11. Testing: Backend Testing — E2E Testing
* Part 12. Testing: Frontend Testing — Unit Testing
* Part 13. Testing: Frontend Testing — Integration Testing


In the previous post, I presented the module UserModule which is used to manage
the information about the user. So, I recommend you that you read the first post
before this because you can understand the whole system.

This post will presented the **AppModule** which is used to manage the request
of the user from an Angular frontend. This module only have a service,
controller and module. The AppService inject the two services: **UserService**
and **AuthService** from the modules **UsersModule** and **AuthModule**. This
service is used as a wrapper which use both services.

So, the first step is show the **AppModule** code:

![](https://cdn-images-1.medium.com/max/1000/1*nTDjaNMQm6NRYtGCpjRZNA.png)

You can see that this module imports **AuthModule** and **UsersModule** which is
very important because the **AppService** injected **AuthService** and
**UsersService**.

So, the next step is develop the controller which contains two routes associated
to clock-in and clock-out which invoke the AppService (which will invoke
AuthService) and one route associate to get the list of users which must be
working now and the timestamp from the server (to get near-realtime which will
invoke **UserService**).

![](https://cdn-images-1.medium.com/max/1000/1*ylB9vZlAUiPjPJjeXtMv5A.png)

So, the final step is develop the AppService which uses the two previously
mentioned services.

![](https://cdn-images-1.medium.com/max/1000/1*cCejQPeTl9pX00FY44xKpQ.png)

### Resume

‌In this post I’ve explain my AppModule which is very simple because I’m using
clean code in my coding. This module is used to communicate client-side
(Angular) and server-side. This module import AuthModule and UsersModule which
exports their services. These services are used to save the information about
the clock-in/out and get all users which must be working.

At the moment, we’ve developed a basic backend with three modules and different
endpoints. In the following post about backend, we will explain about the seed
of the database and testing. However, in the following post of this series we
will explain how to build a basic frontend using Angular and RxJS.

*****

Originally published at [www.carloscaballero.io](https://carloscaballero.io/part-4-clock-in-out-system-basic-backend-iii-appmodule/) on December 14, 2018.