Skip to content

Developer manual

Drilio edited this page Dec 5, 2024 · 27 revisions

Technology overview

Docker

React

Projet inspiré de Bulletproof-react

NestJS

Setup development environment

Code folders overview

Guidelines

Avoiding circular dependencies with nestJS and linkTable

We have implement linkTable with one to many relation with over entities, this allow us to define rights for the entity A on entity B But this introduce circular dependency problem. I manage a structure to handle this.But it allow us to import module A and B into the link module but not the linkModule into module A or B. Module A and Module B take care of there own logic and Link Module handle the logic that concern A AND B modules.

Historic

We used to avoid this problem by creating a C module. This module imported module A & B & Link but this have for side effect to increese code base a lot, we decided to change this into this branch : https://github.com/SCENE-CE/mirador-multi-user/tree/backend-clear-useless-routes

Snippet of code showing the problem :

Here you can see that we import ProjectModule and UserGroupModule into LinkProjectUserGroupModule image

It result into this error : image

Scheme

image

Database migrations

Create a migration

  • run the app with docker compose up
  • connect to backend docker with docker exec -it <name-of-your-backend-container> /bin/sh
  • run npm run typeorm:generate-migration --name=<name-of-the-migration>

Execute migrations

  • docker compose up
  • connect to backend docker with docker exec -it <name-of-your-backend-container> /bin/sh
  • cd /app
  • npm run typeorm migration:run -- -d ./src/config/dataSource.ts

Recreate Db in development (do NOT do this in PRODUCTION)

[TODO] Commpléter

Execute this comands into the backend docker :

  • npm run typeorm:generate-migration --name=db-init
  • npm run typeorm migration:run -- -d ./src/config/dataSource.ts

Promote a use to administrator of the platform

You can't promote a user to admin using the API so you MUST need to directly connect to the db and run this SQL request :

UPDATE multiUsers.`user`
SET `_isAdmin` = 1
WHERE id = <Replace this by the user you want to promote id';

Clone this wiki locally