With poetry
poetry shell
poetry install
Or without poetry
python3 -m venv .venv
source .venv/bin/activate # (for windows use -> $.venv\Scripts\activate.bat)
pip install -r requirements.txt
Generate requirements.txt
poetry export -f requirements.txt --output requirements.txt
with Docker Compose
The following command automatically prepare MongoDB and FastAPI service to run
docker-compose up -d
without Docker Compose
You should have MongoDB server and put configs of it to ".dev.env" file
source .dev.env
uvicorn app.main:app --host localhost --port 8000 --reload
You can reach to service with the URL: "http://localhost:8000/ms-user-candidate/*"
When the service starts the first time, it will create the default user and password, then print them to the terminal.
Please login with the default user/password via /ms-user-candidate/login endpoint, get the access token from the response, and use in headers the token when sending requests to other APIs
ENDPOINTS
-
/ms-user-candidate/login - HTTP POST: Form data: *username: [email protected] *password: 12345678
Status Code: 200 OK
{ "access_token": "XXXX", "refresh_token": "XXXX" }
Status Code: 400 Bad request
{ "detail": "Incorrect email or password" }
-
/ms-user-candidate/user - HTTP POST: Form data: *first_name: Real *last_name: Huseyn *email: [email protected] *password: 12345678 Header: *Authorization: Bearer some_jwt_token
Status Code: 201 Created
{ "uuid": "60012b84-5d86-48dd-9f65-6a056a7a02be", "first_name": "Real", "last_name": "Huseyn", "email": "[email protected]", "password": "$2b$12$2rcTbeXwqkAfxdxoTfRxvekwcREEtIKuP4UiNvZIYNV81ibAP80JG" }
Status Code: 400 Bad request
{ "detail": "User with this email already exist" }
Status Code: 403 Forbidden
{ "detail": "Could not validate credentials" }
You can find other APIs on the swagger: "http://localhost:8000/docs"