Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: a general revision of readme #236

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 43 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,47 +76,71 @@ poetry env use 3.11.4
poetry shell
```

## Run for DEV
## Run locally

### for local development

To start the application outside docker, execute the next command inside a virtual environment.
This will start all the dependencies services on each docker container and the application directly
on the host using the development server:

Start the app's dependencies services:
```bash
RUN_APP=false make run-docker
make run
```

You have to install the app package dependencies and run the migrations.
To start the app and its dependencies on docker, on development mode, run:

```bash
make install-packages migrate
make run-docker
```

To execute the application outside the docker:
You have to install the app package dependencies and run the migrations.
```bash
make run
make install-packages migrate
```

## Run for PROD
### for local testing the production mode

To start the application using the production mode, run:
To check if everything is ok and running using the production mode of the docker images, we have a
wait to run the application on production mode.
This will use the docker target `production` of the docker application image.

```bash
DOCKER_TARGET=production make run-docker
```

## GENERATING AND USING TOKEN
## API

This project uses the Django Rest Framework using a token approach for authentication.

To generate a token you should use one of this two commands:
The important API are:

- /billing/receipt-link/{transaction_id}/
- /billing/transaction-complete/

You can view the API documentation on:

- Swagger http://localhost:8000/api/docs/
- Redocs http://localhost:8000/api/redocs/

### Generate a local token for development

To generate a token for local development you should use one of this two commands:

This will create a token for `admin` user.
```bash
make create-token # will create a token for admin user
make create-token
```
OR

### Generate a token for a production environment

```bash
manage.py drf_create_token user_who_you_want # will create a token for indicated user
```
python manage.py createsuperuser --noinput --username <username> --email <email>

# IN YOUR CODE
To use token you need import he class ```from rest_framework.authentication import TokenAuthentication ```
then in your view declare a variable ```authentication_classes``` as list with ```TokenAuthentication``` class.
python manage.py drf_create_token <username>
```

# IN YOUR CLIENT OR REQUEST
## Client
In Headers of request you need to declare a key 'Authorization' with the value 'Token generated_token'

Here is a example:
Expand Down
Loading