update readme

This commit is contained in:
Gsk54 2023-01-06 15:06:54 +01:00
parent bb82488e0d
commit ece4d28706
2 changed files with 37 additions and 19 deletions

View File

@ -6,32 +6,42 @@ Authentication (AuthN) and Authorization (AuthZ) data management.
You need [Docker](https://docs.docker.com/engine/) and its [compose](https://docs.docker.com/compose/) plugin. You need [Docker](https://docs.docker.com/engine/) and its [compose](https://docs.docker.com/compose/) plugin.
You also need NodeJS installed locally : we **strongly** advise to install [Node Version Manager](https://github.com/nvm-sh/nvm) and use the latest LTS version of Node (check that your local version matches with the one used in the Dockerfile).
The API will run inside a docker container, **but** the install itself is made outside the container, because during development we need tools that need to be available locally (eg. ESLint, Prettier...).
A RabbitMQ instance is also required to send / receive messages when data has been inserted/updated/deleted. A RabbitMQ instance is also required to send / receive messages when data has been inserted/updated/deleted.
## Installation ## Installation
Copy `.env.dist` to `.env` : - copy `.env.dist` to `.env` :
```bash ```bash
cp .env.dist .env cp .env.dist .env
``` ```
and modify it to suit your needs. Modify it if needed.
Then execute : - start the containers :
```bash ```bash
docker compose up -d docker compose up -d
``` ```
The app runs automatically on the port defined in `SERVICE_PORT` of `.env` file (default : _5002_). The app runs automatically on port **5002**.
- install the dependencies :
```bash
npm install
```
## Database migration ## Database migration
Before using the app, you need to launch the database migration : Before using the app, you need to launch the database migration (it will be launched inside the container) :
```bash ```bash
docker exec v3_user sh -c "npx prisma migrate dev" npm run migrate
``` ```
## Usage ## Usage
@ -116,18 +126,25 @@ For AuthN, the app exposes the following [gRPC](https://grpc.io/) services :
Various RabbitMQ messages are sent for logging purpose. Various RabbitMQ messages are sent for logging purpose.
## Test ## Tests
Tests are run outside the container for ease of use (switching between different environments inside containers using prisma is complicated and error prone).
The integration tests use a dedicated database (see *db-test* section of *docker-compose.yml*).
```bash ```bash
# unit tests # run all tests (unit + integration)
docker exec v3_user sh -c "npm run test" npm run test
# test coverage # unit tests only
docker exec v3_user sh -c "npm run test:cov" npm run test:unit
# integration tests only
npm run test:integration
# coverage
npm run test:cov
``` ```
Note : you can run all npm commands directly _outside_ the container (see _scripts_ section of `package.json` for available commands), but you need NodeJS installed locally. We **strongly** advise to install [Node Version Manager](https://github.com/nvm-sh/nvm) and use the latest LTS version of Node.
## License ## License
Mobicoop V3 - Auth Service is [AGPL licensed](LICENSE). Mobicoop V3 - Auth Service is [AGPL licensed](LICENSE).

View File

@ -19,6 +19,7 @@
"test:integration": "npm run migrate-test && dotenv -e .env.test -- jest --testPathPattern 'integration' --verbose", "test:integration": "npm run migrate-test && dotenv -e .env.test -- jest --testPathPattern 'integration' --verbose",
"test:cov": "npm run migrate-test && dotenv -e .env.test -- jest --coverage", "test:cov": "npm run migrate-test && dotenv -e .env.test -- jest --coverage",
"test:e2e": "jest --config ./test/jest-e2e.json", "test:e2e": "jest --config ./test/jest-e2e.json",
"migrate": "docker exec v3-user sh -c 'npx prisma migrate dev'",
"migrate-test": "dotenv -e .env.test -- npx prisma migrate dev --name postgres-init" "migrate-test": "dotenv -e .env.test -- npx prisma migrate dev --name postgres-init"
}, },
"dependencies": { "dependencies": {