A REST API python backend service "filter_message".
Created two services:
- API messaging service.
- Listener for checking messages.
Tested on Ubuntu 20.04 and
Django==4.0.4
django_environ==0.8.1
djangorestframework==3.13.1
djangorestframework_simplejwt==5.1.0
environ==1.0
kafka==1.3.5
requests==2.27.1
pip==22.0.4
API methods are divided into two types:
- GET/POST methods for the user.
- POST method for listener/consumer message_confirmation.
-
Standart auth
- accounts/
- accounts/login
- accounts/signup
- accounts/
-
JWT auth
- api/token/
- api/token/refresh/
- api/token/verify/
-
Message
- api/message/
-
Message confirmation
- api/message_confirmation/
Endpoints example:
Request:
GET http://127.0.0.1:8000/api/message
Response:
[
{
"message_text":"Hi",
"user_to":1},
{
"message_text":"Hi",
"user_to":1}
]
Request:
POST http://127.0.0.1:8000/api/token/
Content type: application/json
{
"username": "alexander",
"password": 123
}
Response:
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b...",
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2..."
}
for more info look Test
These instructions will get you a copy of the project up and running on your local machine. There are two ways to run a project.
- run without Docker
- run with Docker
Clone the repository
git clone https:https://github.com/Alexander671/filter_message/
Navigate into the filter_message
directory
cd filter_message/filter_message
Create user and password in filter_message app to get jwt token
python3 manage.py createsuperuser
For correct work you need to create .env file in ~/PROJECT_DIR/filter_message/filter_message/.env with the following content:
nano .env
# example
# your django_secret_key
SECRET_KEY="django-insecure-8)+2eujbv7(i0if^h%mmjtxzwz8l1br2^sgcx&w0x*@@uy5@nx"
DEBUG=True
ALLOWED_HOSTS=
# message server
HOST_SERVER=http://127.0.0.1:8000/
# need to create user and password
# in filter_message app
# to get jwt
LOGIN=alexander
PASSWORD=1
Install, using pip
:
pip install -r requirements.txt
python3 manage.py makemigrations
python3 manage.py migrate
chmod +x start.sh
./start.sh
Clone the repository
git clone https://github.com/Alexander671/filter_message/
Navigate into the filter_message
directory
cd filter_message/filter_message
Create user and password in filter_message app to get jwt token
python3 manage.py createsuperuser
For correct work you need to create .env file in ~/PROJECT_DIR/filter_message/filter_message/.env with the following content:
nano .env
# example
# your django_secret_key
SECRET_KEY="django-insecure-8)+2eujbv7(i0if^h%mmjtxzwz8l1br2^sgcx&w0x*@@uy5@nx"
DEBUG=True
ALLOWED_HOSTS=
# message server
HOST_SERVER=http://127.0.0.1:8000/
# need to create user and password
# in filter_message app
# to get jwt
LOGIN=alexander
PASSWORD=1
- Build the image
docker build .
- Š”ompiling the image with the team
docker-compose build
- Run container:
docker-compose up -d
Some edge-cases examples are available on the test_postman
- Alexander Matveev - Initial work - Alexander671