You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
4.7 KiB
86 lines
4.7 KiB
# REST API - MemoryMap
|
|
|
|
[](https://codefirst.iut.uca.fr/SAE3A_MemoryMap/api)
|
|
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
[](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api)
|
|
|
|
|
|
> Made with FastAPI (Python)
|
|
|
|
## Documentation
|
|
|
|
You can find the official documentation for the project at https://api.memorymap.fr/docs (or https://api.memorymap.fr/redoc)
|
|
|
|
## How to run it
|
|
|
|
> If you want to try the API on the production environment, please look at the documentation
|
|
|
|
### Prerequisites
|
|
|
|
- Docker
|
|
|
|
### Running the Application
|
|
|
|
1. **Clone the repository**:
|
|
```bash
|
|
git clone https://codefirst.iut.uca.fr/git/SAE3A_MemoryMap/api.git
|
|
cd api
|
|
```
|
|
|
|
2. **Create a `.env` file**:
|
|
Create a `.env` file in the root directory of your project and add the following environment variables:
|
|
```env
|
|
MONGODB_URL=mongodb://localhost:27017/
|
|
MONGODB_USERNAME=mongoadmin
|
|
MONGODB_PASSWORD=secret
|
|
MONGODB_DATABASE=memorymap
|
|
JWT_SECRET_KEY=your_jwt_secret_key
|
|
JWT_ALGORITHM=HS256
|
|
JWT_ACCESS_TOKEN_EXPIRE_MINUTES=30
|
|
```
|
|
|
|
3. **Build the docker image for the API**:
|
|
```bash
|
|
docker build -t memorymap_api -f docker/Dockerfile .
|
|
```
|
|
|
|
4. **Run the MongoDB container**:
|
|
```bash
|
|
docker run -d -p 27017:27017 --name mongodb -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret mongo:8.0.3-noble
|
|
```
|
|
|
|
5. **Run the API container**:
|
|
```bash
|
|
docker run -d -p 8000:8000 --name memorymap_api --env-file .env memorymap_api
|
|
```
|
|
|
|
6. **Access the API**:
|
|
The API will be available at `http://localhost:8000` and the documentation at `http://localhost:8000/docs` (or `http://localhost:8000/redoc`)
|
|
|
|
### Running Tests
|
|
|
|
1. **Install test dependencies**:
|
|
```bash
|
|
pip install -r tests/requirements.txt
|
|
```
|
|
|
|
2. **Run the MongoDB container**:
|
|
⚠ Do **not** change USERNAME / PASSWORD values
|
|
```bash
|
|
docker run -d -p 27017:27017 --name mongodb -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret mongo:8.0.3-noble
|
|
```
|
|
|
|
2. **Run the tests**:
|
|
```bash
|
|
pytest
|
|
``` |