Skip to content

Commit caf3293

Browse files
authored
Merge pull request #1 from mapswipe/feat/api-example
2 parents bc332e7 + 12e3fb8 commit caf3293

8 files changed

Lines changed: 634 additions & 2 deletions

File tree

.github/workflows/git.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Lint commits
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
lint:
7+
name: Commit Lint
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@main
11+
- uses: toggle-corp/commit-lint@main

.github/workflows/pre-commit.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: CI
22

33
on:
44
pull_request:
5+
push:
6+
branches:
7+
- "main"
58

69
jobs:
710
pre_commit_checks:

.lycheeignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
https://slack.com/shortcuts/Ft09CHNNHZNX/8d0d6f7d69a1350a91b2ef33fc6d5704
2+
https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword
23
https://www.mdpi.com/2072-4292/8/10/859
4+
5+
# 404
6+
https:\/\/backend-(\d+)\.mapswipe\.dev\.togglecorp\.com
7+
https://backend-stage.mapswipe.org
8+
https://backend.mapswipe.org

docs/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
### Old Architecture
1515
<figure>
1616
<IMG
17-
src="/assets/images/overview/old_architecture.png"
17+
src="/assets/docs/overview/images/old_architecture.png"
1818
alt="Prev arch"/>
1919
<figcaption>Previous MapSwipe Architectural Flow</figcaption>
2020
</figure>
@@ -31,7 +31,7 @@ Furthermore, A background worker periodically synchronized (partially) the 2 dat
3131
### New Architecture
3232
<figure>
3333
<IMG
34-
src="/assets/images/overview/new_architecture.png"
34+
src="/assets/docs/overview/images/new_architecture.png"
3535
alt="New architecture"/>
3636
<figcaption>New MapSwipe Architectural Flow</figcaption>
3737
</figure>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
## Background
2+
3+
This script is provided as an example for interacting with the MapSwipe backend.
4+
5+
> [!CAUTION]
6+
> Ongoing updates to the backend might render this script **out-of-date**.
7+
8+
## Getting started
9+
10+
> [!NOTE]
11+
> You will need Manager account credentials to run this script.
12+
13+
- Create `.env` file.
14+
- Define the following variables:
15+
- `MANAGER_URL`: URL for Manager Dashboard
16+
- `BACKEND_URL`: URL for Backend
17+
- `CSRFTOKEN_KEY`: CSRF Token Key
18+
- `ENABLE_AUTHENTICATION`
19+
- `FB_AUTH_URL`: Authentication URL
20+
- `FB_USERNAME`: Manager account username
21+
- `FB_PASSWORD`: Manager account password
22+
- For `FB_AUTH_URL`,
23+
- Sign-in on the Manager Dashboard and open Dev Console.
24+
- Look for the URL which starts with https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword
25+
<img width="1305" height="228" alt="image" src="https://github.com/user-attachments/assets/332e6673-f0e3-48c4-8420-13ef5d648f21" />
26+
27+
### Alpha Instance
28+
29+
> [!CAUTION]
30+
> The alpha instance is running inside Togglecorp's domain for internal testing.
31+
32+
Your final `.env` for alpha instance should look like this:
33+
34+
```dotenv
35+
MANAGER_URL=https://manager-2.mapswipe.dev.togglecorp.com
36+
BACKEND_URL=https://backend-2.mapswipe.dev.togglecorp.com
37+
CSRFTOKEN_KEY=MAPSWIPE-ALPHA-2-CSRFTOKEN
38+
39+
ENABLE_AUTHENTICATION=true
40+
FB_AUTH_URL=https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
41+
# Your web-app login credential
42+
FB_USERNAME=me@example.com
43+
FB_PASSWORD=my-very-good-password
44+
```
45+
46+
### Staging Instance
47+
48+
Your final `.env` for staging instance should look like this:
49+
50+
```dotenv
51+
MANAGER_URL=https://managers-stage.mapswipe.org
52+
BACKEND_URL=https://backend-stage.mapswipe.org
53+
CSRFTOKEN_KEY=MAPSWIPE-STAGE-CSRFTOKEN
54+
55+
ENABLE_AUTHENTICATION=true
56+
FB_AUTH_URL=https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
57+
# Your web-app login credential
58+
FB_USERNAME=me@example.com
59+
FB_PASSWORD=my-very-good-password
60+
```
61+
62+
### Production Instance
63+
64+
Your final `.env` for production instance should look like this:
65+
66+
```dotenv
67+
MANAGER_URL=https://managers.mapswipe.org
68+
BACKEND_URL=https://backend.mapswipe.org
69+
CSRFTOKEN_KEY=MAPSWIPE-PROD-CSRFTOKEN
70+
71+
ENABLE_AUTHENTICATION=false
72+
FB_AUTH_URL=https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
73+
# Your web-app login credential
74+
FB_USERNAME=me@example.com
75+
FB_PASSWORD=my-very-good-password
76+
```
77+
78+
## Running the script
79+
80+
Run the example script using uv
81+
82+
```bash
83+
uv run run.py
84+
```
85+
86+
> [!NOTE]
87+
> To install uv, visit https://docs.astral.sh/uv/getting-started/installation/

0 commit comments

Comments
 (0)