atcoder-problems-backend
is a set of backend applications written in Rust.
Since the web app, which is running on your local machine, connects to the production backend server, you don't need to run the backend applications in most cases.
Note that the following steps assume that your frontend application runs on http://localhost:3000 and your backend application runs on http://localhost:8080, which are the default values.
- Create a GitHub app.
Keep the client ID and the client secret.
- Remember to set the "User authorization callback URL" to
http://localhost:8080/internal-api/authorize
.
- Remember to set the "User authorization callback URL" to
- Launch an instance of PostgreSQL database on your machine.
To prevent accidentally committing the changes below, you may want to ignore these files locally before editing them by adding the paths of these files to the
$GIT_DIR/info/exclude
file, if you do not intend to commit changes in these files. ($GIT_DIR
is usually the.git
folder.)
Below are the list of files you need to modify:
atcoder-problems-backend/src/server/endpoint/internal_api/mod.rs
: changeREDIRECT_URL
tohttp://localhost:3000/atcoder/
for your backend to redirect to your frontend web app after logging in.atcoder-problems-frontend/src/setupProxy.js
: changetarget
tohttp://localhost:8080
and remove thepathRewrite
section for your frontend web app to use your backend server.atcoder-problems-frontend/src/utils/Url.tsx
: changeCLIENT_ID
to the client ID of your GitHub app and changeAUTHORIZATION_CALLBACK_URL
tohttp://localhost:8080/internal-api/authorize
.
Be careful not to commit these files to the Git repository.
docker-compose up -d
docker-compose exec backend-development cargo build
export SQL_URL=... # Connection URL of PostgreSQL
export CLIENT_ID=... # GitHub client_id, which is required to use the login function.
export CLIENT_SECRET=... # GitHub client_secret, which is required to use the login function.
# Run backend server
cargo run --bin run_server
# Run crawlers
cargo run --bin crawl_all_submissions
cargo run --bin crawl_for_virtual_contests
cargo run --bin crawl_from_new_contests
cargo run --bin crawl_problems
cargo run --bin crawl_recent_submissions
cargo run --bin crawl_whole_contest <contest_id>
# Run other tools
cargo run --bin batch_update
cargo run --bin delta_update
cargo run --bin dump_json
cargo run --bin fix_invalid_submissions
docker-compose up -d
docker-compose exec backend-development cargo test --workspace -- --test-threads=1
GitHub Action will check if the code base is formatted by rustfmt
.
Please make sure that your change is formatted before sending a pull request.
You can format the code base with cargo fmt
like the following:
docker-compose up -d
docker-compose exec backend-development cargo fmt