"app-hub-back" is the back-end component of the App Hub project, developed using NestJS. This repository serves as the engine behind the scenes, handling authentication, data storage, and communication with the front-end. It provides the necessary APIs and services for managing the application catalog, user accounts, and secure connections.
npm install
Before running the application, you will have to add, at the root level of the project an .env file from the .env.example file.
# development
npm run start
# watch mode
npm run start:dev
# production mode
npm run start:prod
# unit tests
npm run test
# e2e tests
npm run test:e2e
# test coverage
npm run test:cov
While the application is running, you can see the documentation about the endpoint at the following web page : Swagger documentation.
You can see the associated commands at the prisma\dbml\schema.dbml file.
After filling the .env file you can fill your database with some mock users and applications (defined in mock/ folder). Then to populate this data into your database, you will have to run the following commands : npx prisma db seed
.
If you want to update the database, you can do it by running npx prisma db studio
, and then access to the following web page : Prisma Studio.
If you update the database (by editing the prisma/schema.prisma file) after evaluating its validation with npx prisma validate
, you have to update the associated compiled files by running npx prisma generate
and then you may need to update the database with npx prisma db push
.
You should as well edit the following picture : README.assets\ms-users.png, by copy the content from prisma\dbml\schema.dbml to dbdiagram.io.
Folder | Purpose |
---|---|
app.controller.ts |
A basic controller with a single route. |
app.controller.spec.ts |
The unit tests for the controller. |
app.module.ts |
The root module of the application. |
app.service.ts |
A basic service with a single method. |
main.ts |
The entry file of the application which uses the core function NestFactory to create a Nest application instance. |
For nestJS project, in general :
- Modules: used to organize the code and split features into logical reusable units. Grouped TypeScript files are decorated with “@Module” decorator which provides metadata that NestJs makes use of to organize the application structure.
- Providers: also called services, which are designed to abstract any form of complexity and logic. Providers can be created and injected into controllers or other providers.
- Controllers: responsible for handling incoming requests and returning appropriate responses to the client-side of the application (for example call to the API).
To update the above graph, run the following command : npm run doc:graph
.
- "Entities" : refer to units of composition of the overall system data. They normally represent business objects like: bank accounts, employees, products, etc. They can be used to persist the state of the system to a database. => prisma.io
- "Data transfer objects" : are ephemeral collections of data transferred for a very specific purpose. For example, to display a list of products of a specific kind to an end user. You do not want to send all of the data that represents every product entity to the user, but only what is needed for this purpose. => example.dto.ts
Dockerfile
- This file will be responsible for importing the Docker images, dividing them into development and production environments, copying all of our files, and installing dependencies.docker-compose.yml
- This file will be responsible for defining our containers, required images for the app other services, storage volumes, environment variables, etc.
Run the following commands at the root directory :
docker compose build
docker compose up
The backend application has been developped with NestJS. It is a progressive Node.js framework for building efficient, reliable and scalable server-side applications. As this framework supports as well development in TS, we choose these typed language as a safety harness. Useful documentations are available at the following links :
NestJs CLI offers a bunch of command to ease developpers' works. Useful documentations are available at the following links :
Authentification of the user is supported by JWON Web Token (JWT). Useful documentations are available at the following links :
The interaction with the database is supported by a TypeScript ORM (Object–relational mapping) : Prisma. Useful documentations are available at the following links :
To ease the deployment of our application, it has been drafted docker files. They have not been tested yet due to a lack of CPU ressources of the current developper's computer. Useful documentations are available at the following links :