From 62ebabb55595aca20525524906e80b864b4d8f24 Mon Sep 17 00:00:00 2001 From: Jamie Choi Date: Sun, 12 Jul 2020 16:14:51 +0800 Subject: [PATCH 1/3] docs: improve development-related documentations --- atcoder-problems-backend/README.md | 29 ++++++++++++++++++++++++++++- atcoder-problems-frontend/README.md | 15 +++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/atcoder-problems-backend/README.md b/atcoder-problems-backend/README.md index be36428ce..f47d79286 100644 --- a/atcoder-problems-backend/README.md +++ b/atcoder-problems-backend/README.md @@ -5,6 +5,33 @@ 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 +> and your backend application runs on , which are the default values. + +## Prerequisites + +1. [Create a GitHub app](https://docs.github.com/en/developers/apps/creating-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`. +2. Launch an instance of [**PostgreSQL**](https://www.postgresql.org/) on your machine. + +## Modifying Files + +Below are the list of files you need to modify: + +- `atcoder-problems-backend/src/server/auth.rs`: change `redirect_url` to `http://localhost:3000/atcoder/#/login/user` + for your backend to redirect to your frontend web app. +- `atcoder-problems-frontend/src/setupProxy.js`: change `target` to `http://localhost:8080` + for your frontend web app to use your backend server. +- `atcoder-problems-frontend/src/utils/Url.tsx`: change `GITHUB_LOGIN_LINK` to `https://github.com/login/oauth/authorize?client_id=`, + where `` is the client ID of your GitHub app. +- (For running backend tests) `atcoder-problems-backend/tests/utils.rs`: change `SQL_URL` + to the correct connection URL. **Note that** it should be different from the database + you intend to develop on. + +**Be careful** not to commit these files to the Git repository. + ## Build ```bash @@ -15,7 +42,7 @@ cargo build ## Run ```bash -export SQL_URL=... # URL of PostgreSQL +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. diff --git a/atcoder-problems-frontend/README.md b/atcoder-problems-frontend/README.md index c5b7113b1..b1ea6db86 100644 --- a/atcoder-problems-frontend/README.md +++ b/atcoder-problems-frontend/README.md @@ -2,7 +2,7 @@ `atcoder-problems-frontend` is a web application written in TypeScript. -## Prerequirements +## Prerequisites - [Yarn](https://yarnpkg.com/) @@ -18,7 +18,18 @@ yarn yarn start ``` -You can see it on http://localhost:3000/ +You can see it on . + +## Login on the local instance + +To log in on your local instance for developing features related to logged in users: + +1. Login at and open the developer tools (Press F12). +1. Go to "Storage" (Mozilla Firefox) / "Application" (Google Chrome) → "Cookies" and copy the cookie value with name `token`. +1. Open the local instance of AtCoder Problems in your browser (e.g. ). +1. Open the "Cookies" section again and create a cookie named `token`. Paste the cookie value. + +If you intend to use your own instance of backend, consult the [backend documentation](../atcoder-problems-backend/README.md). ## Create a production build From 7e2e2f22e974e1049203c878ef98278e5d19962e Mon Sep 17 00:00:00 2001 From: Jamie Choi Date: Sun, 12 Jul 2020 16:17:50 +0800 Subject: [PATCH 2/3] docs: small wording changes --- atcoder-problems-backend/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atcoder-problems-backend/README.md b/atcoder-problems-backend/README.md index f47d79286..559554b62 100644 --- a/atcoder-problems-backend/README.md +++ b/atcoder-problems-backend/README.md @@ -14,14 +14,14 @@ production backend server, you don't need to run the backend applications in mos Keep the **client ID** and the **client secret**. - Remember to set the "User authorization callback URL" to `http://localhost:8080/internal-api/authorize`. -2. Launch an instance of [**PostgreSQL**](https://www.postgresql.org/) on your machine. +2. Launch an instance of [**PostgreSQL**](https://www.postgresql.org/) database on your machine. ## Modifying Files Below are the list of files you need to modify: - `atcoder-problems-backend/src/server/auth.rs`: change `redirect_url` to `http://localhost:3000/atcoder/#/login/user` - for your backend to redirect to your frontend web app. + for your backend to redirect to your frontend web app after logging in. - `atcoder-problems-frontend/src/setupProxy.js`: change `target` to `http://localhost:8080` for your frontend web app to use your backend server. - `atcoder-problems-frontend/src/utils/Url.tsx`: change `GITHUB_LOGIN_LINK` to `https://github.com/login/oauth/authorize?client_id=`, From 4de42cbf32d63a4589cee953dbf6ce568163e3e8 Mon Sep 17 00:00:00 2001 From: Jamie Choi Date: Sun, 12 Jul 2020 16:30:48 +0800 Subject: [PATCH 3/3] docs: use consistent list numbering --- atcoder-problems-backend/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atcoder-problems-backend/README.md b/atcoder-problems-backend/README.md index 559554b62..fd12cc6d2 100644 --- a/atcoder-problems-backend/README.md +++ b/atcoder-problems-backend/README.md @@ -14,7 +14,7 @@ production backend server, you don't need to run the backend applications in mos Keep the **client ID** and the **client secret**. - Remember to set the "User authorization callback URL" to `http://localhost:8080/internal-api/authorize`. -2. Launch an instance of [**PostgreSQL**](https://www.postgresql.org/) database on your machine. +1. Launch an instance of [**PostgreSQL**](https://www.postgresql.org/) database on your machine. ## Modifying Files