DEV Community

Cover image for Part 4. Clock-in/out System - Basic backend (III) - AppModule
Carlos Caballero
Carlos Caballero

Posted on • Edited on • Originally published at carloscaballero.io

Part 4. Clock-in/out System - Basic backend (III) - AppModule

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:

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:

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).

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

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 on December 14, 2018.

Top comments (0)