updated web api docs
This commit is contained in:
parent
2a828df0d7
commit
94f740fe07
2 changed files with 18 additions and 35 deletions
|
@ -24,19 +24,7 @@ Discord OAuth2 callback
|
||||||
|
|
||||||
### REST
|
### REST
|
||||||
|
|
||||||
#### `/users/new`
|
#### `/user-data`
|
||||||
|
|
||||||
Create a new user
|
|
||||||
|
|
||||||
#### `/users/find`
|
|
||||||
|
|
||||||
Find a user
|
|
||||||
|
|
||||||
#### `/users`
|
|
||||||
|
|
||||||
List all users in the database
|
|
||||||
|
|
||||||
#### `/list-servers`
|
|
||||||
|
|
||||||
List all servers in the database
|
List all servers in the database
|
||||||
|
|
||||||
|
|
|
@ -20,17 +20,9 @@ This page will teach you how to set up the [Llama bot web API](https://github.co
|
||||||
2. Go to the OAuth2 tab.
|
2. Go to the OAuth2 tab.
|
||||||
3. Add the following redirect URIs:
|
3. Add the following redirect URIs:
|
||||||
|
|
||||||
- localhost for testing
|
- localhost for testing (http only): `http://localhost:5001/<YOUR_FIREBASE_PROJECT_ID_HERE>/us-central1/api/auth`
|
||||||
|
- http: `http://us-central1-<YOUR_FIREBASE_PROJECT_ID_HERE>.cloudfunctions.net/api/auth`
|
||||||
- `http://localhost:5001/<project-id>/us-central1/api`
|
- https: `https://us-central1-<YOUR_FIREBASE_PROJECT_ID_HERE>.cloudfunctions.net/api/auth`
|
||||||
- `http://localhost:5001/<project-id>/us-central1/api/auth`
|
|
||||||
|
|
||||||
- http
|
|
||||||
- `http://us-central1-<project-id>.cloudfunctions.net/api`
|
|
||||||
- `http://us-central1-<project-id>.cloudfunctions.net/api/auth`
|
|
||||||
- https
|
|
||||||
- `https://us-central1-<project-id>.cloudfunctions.net/api`
|
|
||||||
- `https://us-central1-<project-id>.cloudfunctions.net/api/auth`
|
|
||||||
|
|
||||||
### Firebase
|
### Firebase
|
||||||
|
|
||||||
|
@ -41,8 +33,7 @@ This page will teach you how to set up the [Llama bot web API](https://github.co
|
||||||
https://console.firebase.google.com
|
https://console.firebase.google.com
|
||||||
|
|
||||||
2. Create/Select a project. Make sure it is using the [blaze plan](https://firebase.google.com/pricing).
|
2. Create/Select a project. Make sure it is using the [blaze plan](https://firebase.google.com/pricing).
|
||||||
3. Go to the `Authentication` tab and enable `Email/Password` Authentication.
|
3. Go to the `Firestore Database` tab and enable it (using production mode is highly recommended).
|
||||||
4. Go to the `Firestore Database` tab and enable it (using production mode is highly recommended).
|
|
||||||
|
|
||||||
### Local
|
### Local
|
||||||
|
|
||||||
|
@ -60,12 +51,12 @@ This page will teach you how to set up the [Llama bot web API](https://github.co
|
||||||
git clone git@github.com:llama-bot/llama-bot-web-api.git
|
git clone git@github.com:llama-bot/llama-bot-web-api.git
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Create `functions/src/config.json` and fill in the data.
|
2. Edit `functions/src/config.json`.
|
||||||
|
|
||||||
```json title="functions/src/config.json"
|
```json title="functions/src/config.json"
|
||||||
{
|
{
|
||||||
"region": "FIREBASE_FUNCTIONS_REGION_HERE", // Region where firebase functions is hosted in. Example: us-central1
|
"region": "FIREBASE_FUNCTIONS_REGION_HERE", // Region where firebase functions is hosted in. Example: us-central1
|
||||||
"scopes": ["DISCORD", "SCOPES", "HERE"] // Discord OAuth2 scopes. Example: ["identify", "email"]
|
"scopes": ["DISCORD", "SCOPES", "HERE"] // Discord OAuth2 scopes. Example: ["identify", "email", "guilds"]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -80,19 +71,21 @@ This page will teach you how to set up the [Llama bot web API](https://github.co
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Install firebase cli tools.
|
4. Go to [this link](https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk), select your firebase project and download the firebase admin sdk key by pressing the "Generate new private key" button. Rename it to `firebase-adminsdk.json` and put it in `functions/src/`.
|
||||||
|
|
||||||
|
5. Install firebase cli tools.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g firebase-tools
|
npm install -g firebase-tools
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Select firebase project
|
6. Select firebase project
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
firebase use <firebase-project-id>
|
firebase use <firebase-project-id>
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Go to `functions` directory and install necessary dependencies.
|
7. Go to `functions` directory and install necessary dependencies.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install
|
npm install
|
||||||
|
@ -100,19 +93,21 @@ This page will teach you how to set up the [Llama bot web API](https://github.co
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
1. Start local test server by running the following command:
|
1. Start local test server by running the following command in the `functions` directory.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run serve
|
npm run serve
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Open locally served API and log in with your discord account.
|
2. Open locally served API and log in with your discord account.
|
||||||
|
|
||||||
:::warning
|
:::warning
|
||||||
HTTP**S** won't work when serving locally. Use HTTP instead.
|
HTTP**S** won't work when serving locally. Use HTTP instead.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
Login test URI: `http://localhost:5001/<FIREBASE-PROJECT-ID>/us-central1/api/login`
|
Login test URI: `http://localhost:5001/<YOUR_FIREBASE_PROJECT_ID_HERE>/us-central1/api/login`
|
||||||
|
|
||||||
3. If everything is set up correctly, this should have added a new user that you can check it in the firebase `Authentication` tab.
|
3. If everything is set up correctly, this should have added a new user in firestore database.
|
||||||
|
|
||||||
### Deploying
|
### Deploying
|
||||||
|
|
||||||
|
@ -122,7 +117,7 @@ Deploying the functions to production is as simple as running the following comm
|
||||||
firebase deploy
|
firebase deploy
|
||||||
```
|
```
|
||||||
|
|
||||||
Production API URI: `https://us-central1-<firebase-project-id>.cloudfunctions.net/api`.
|
Production API URL: `https://us-central1-<YOUR_FIREBASE_PROJECT_ID_HERE>.cloudfunctions.net/api`.
|
||||||
|
|
||||||
## More info
|
## More info
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue