Backend
Programming languages and frameworks used
The backend is written in TypeScript with the Node.js runtime environment.
It articulates around the Express web framework. Controllers are built using the tsoa tool to produce a fully OpenAPI-compliant API. Dependency injection uses tsyringe. Authentication is managed using Passport.
INFO
If there is a need to add other types of authentication methods, such as Single-Sign-On (SSO), refer to strategies defined in backend/src/config/passport.ts.
Tests are written using the Vitest framework, which has a one-to-one API compatible with Jest.
File structure
src/server.ts: backend entry point.
src/app.ts: Express app setup (middlewares, routes, error handling).
src/authentication.ts: authentication helpers and guards used by controllers.
src/controllers: API controllers (tsoa endpoints).
src/services: business logic used by controllers.
src/models: database entities and ORM models.
src/dtos: request/response DTOs used by the API.
src/migrations: database migration files.
src/config: technical configuration (CORS, data source, Passport, etc.).
src/constants: shared constants.
src/types and src/types.d.ts: shared custom TypeScript types.
src/tests: backend test helpers and fixtures.
Usage
It is prefered during development that you do not launch the backend using Docker but rather directly using Node. The Docker image is not automatically updated after each modification and will not reflect your change unless you explicitly tell Docker to build the image again.
Go inside the backend folder
cd backendInstall the right dependencies
npm installLaunch the app in development mode
npm run devLint
The linter finds variable that haven't been declared, unused imports, any usage of "any" (bad practice) etc.
npm run lintIf the previous command yields error that it can easily fix without breaking changes, you can fix them
npm run lint:fixFormat
The formatter (Prettier) changes the disposition of the code in the file (spacing, etc)
npm run formatBuild
Building transpiles your code into JavaScript code. It's good practice to test you haven't break the build from time to time.
npm run buildTest
npm run test