This repository contains the server-side implementation of an application called "Missions."
- User registration
- Authentication
- Registering, reading, updating, and deleting
DailyMission
- Retrieving and increasing experience points
- Resetting the completion status of daily missions
The update query for all users is implemented in./mission_resetter
.
It is built based on Domain-Driven Design (DDD).
touch mysql_config
in mysql_config file
MYSQL_ROOT_PASSWORD=example_password
MYSQL_USER=example
MYSQL_PASSWORD=example_pass
MYSQL_DATABASE=missions_db
MYSQL_ALLOW_EMPTY_PASSWORD=false
touch .env
you need to set 3 environment
ALLOW_ORIGIN, DATABASE_URL and FILE_PATH of CSV file
ALLOW_ORIGIN=http://localhost:3000
DATABASE_URL=mysql://example:example_pass@localhost:13306/missions_db
FILE_PATH=/home/my_user/develop/missions-systems/exp_table.csv
docker compose up
Install sqlx_cli
cargo install sqlx-cli
sqlx database create
sqlx migrate run
cargo build --release
./target/release/app_server
./target/release/mission_resetter
method: POST
url: http://localhost:8080/user
payload:
{
"userName": "Example",
"email": "[email protected]",
"password": "examplePass"
}
method: POST
url: http://localhost:8080/login
request-body:
{
"email": "[email protected]",
"password": "examplePass"
}
method: GET
url: http://localhost:8080/user
response-body:
{
"userId": "2c639af8-12bb-4140-a3c4-f3aa7e1c6913",
"userName": "Example"
}
method: PUT
url: http://localhost:8080/user?user_name=update_name
method: DELETE
url: http://localhost:8080/user
method: POST
url: http://localhost:8080/daily
request-body:
{
"title": "Read book",
"description": "Read WebAPI books"
}
method: GET
url: http://localhost/daily
response-body:
[
{
"userId": "2c639af8-12bb-4140-a3c4-f3aa7e1c6913",
"missionId": "8b21e122-8411-42f2-9c6f-0415fe824ee1",
"title": "Read book",
"description": "Read WebAPI books",
"isComplete": false
},
{
"userId": "2c639af8-12bb-4140-a3c4-f3aa7e1c6913",
"missionId": "ed78957a-70b5-46db-88e2-b9f1be89e934",
"title": "Cooking",
"description": null,
"isComplete": false
},
]
method: GET
url: http://localhost:8080/daily/:id
:id
is dynamic path. It is missionId.
response-body:
if url is http://localhost:8080/daily/8b21e122-8411-42f2-9c6f-0415fe824ee1
{
"userId": "2c639af8-12bb-4140-a3c4-f3aa7e1c6913",
"missionId": "8b21e122-8411-42f2-9c6f-0415fe824ee1",
"title": "Read book",
"description": "Read WebAPI books",
"isComplete": false
}
method: PUT
url: http://localhost:8080/daily/:id
:id
is dynamic path. It is missionId.
request-body:
if you would like to update a daily mission, you need to set url like this
http://localhost:8080/daily/8b21e122-8411-42f2-9c6f-0415fe824ee1
and set body
{
"title": "update daily mission!",
"description": "update!"
}
method: DELETE
url: http://localhost:8080/daily/:id
:id
is dynamic path. It is missionId.
if you would like to delete a daily mission, you need to set url like this
http://localhost:8080/daily/8b21e122-8411-42f2-9c6f-0415fe824ee1
Set DailyMission's complete true.
Setting "complete" to true will increase the user's experience points (by 2 points) behind the scenes
{
"userId": "2c639af8-12bb-4140-a3c4-f3aa7e1c6913",
"missionId": "8b21e122-8411-42f2-9c6f-0415fe824ee1",
"title": "Read book",
"description": "Read WebAPI books",
"isComplete": true
// ++++++ set true from false
}
method: PUT
url: http://localhost:8080/daily/complete/:id
if you would like to set complete=true
a daily mission, you need to set url like this
http://localhost:8080/daily/complete/8b21e122-8411-42f2-9c6f-0415fe824ee1
method: GET
url: http://localhost:8080/exp
response-body:
{
"userId": "2c639af8-12bb-4140-a3c4-f3aa7e1c6913",
"experiencePoints": 8,
"level": 0
}
Experience point is defined at CSV file
At 20:00 UTC (5:00 AM Japan time), an UPDATE statement is issued for all users' DailyMissions to reset isComplete to false.