- Download and install Docker daemon and docker-compose.
- (Optional) Download and install Postman
-
Manually generate a string of random characters and insert it into
.env
file afterSECRET_KEY=
:SECRET_KEY='<your_strting_here>'
-
Open your OS terminal, change the working directory to the project and run the command below: (if you already have another app running on port 8000, please find the line
- 8000:8080
and replace 8000 with a free port):docker-compose -p cbtask up -d --build
This will install and run the app
For your convenience I created the endpoints collection that you can import into your Postman. Just open Postman and import Users-API.postman_collection.json
file that comes with the project
NOTE 1: if you changed the port please use it in the steps below instead of 8000.
NOTE 2: All endpoint specs are described in API Doc below
- Create a user: the DB is empty, so you'll need to create the first user by using create user endpoint
- Send
username
andpassword
that you created login endpoint to authenticate - In response you will receive an auth token (session duration: 30 min). You should use it to get authorized in all other endpoints:
3.1 (Postman) In the "Authorization" tab of a request choose
Type: Bearer Token
and insert your token into the "Token" field 3.2 If you use curl or any other client you'll need to pass header:Authorization: Bearer <token>
- create user
- login
- view all users
- view user by id
- update user by id
- delete user by id
- purge user by id
Endpoint:
Method: POST
Type: FORMDATA
URL: http://localhost:8000/users/create
Body:
Key | Value |
---|---|
username | john_doe |
password | qwerty123 |
[email protected] | |
info | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
Endpoint:
Method: POST
Type: FORMDATA
URL: http://localhost:8000/login
Body:
Key | Value |
---|---|
username | john_doe |
password | qwerty123 |
Endpoint:
Method: GET
Type:
URL: http://localhost:8000/users
Query params:
Key | Value | Description |
---|---|---|
page | 1 | Default: 1 |
per_page | 10 | Default: 10 |
Endpoint:
Method: GET
Type:
URL: http://localhost:8000/users/:id
URL variables:
Key | Value |
---|---|
id | 1 |
Endpoint:
Method: POST
Type: FORMDATA
URL: http://localhost:8000/users/update/:id
URL variables:
Key | Value |
---|---|
id | 1 |
Body:
Key | Value |
---|---|
info | Changed info |
Endpoint:
Method: DELETE
Type:
URL: http://localhost:8000/users/delete/:id
URL variables:
Key | Value |
---|---|
id | 1 |
Endpoint:
Method: DELETE
Type:
URL: http://localhost:8000/users/purge/:id
URL variables:
Key | Value |
---|---|
id | 1 |