Skip to content

Commit

Permalink
Modify project to resemble RIVER
Browse files Browse the repository at this point in the history
  • Loading branch information
evanjt committed Jan 5, 2024
1 parent cc083da commit 8d61152
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
# sensormap-bff
The backend-for-frontend for sensormap
# astroriver-bff
The backend-for-frontend for astroriver


## Getting started

The app requires the following environment variables:
```
KEYCLOAK_CLIENT_ID
KEYCLOAK_REALM
KEYCLOAK_URL
KEYCLOAK_CLIENT_ID # The UI client ID
KEYCLOAK_BFF_ID # The BFF client ID
KEYCLOAK_BFF_SECRET # The BFF client's secret
```

To start the app run:

```
KEYCLOAK_CLIENT_ID=test \
KEYCLOAK_BFF_ID=test \
KEYCLOAK_BFF_SECRET=test \
KEYCLOAK_REALM=realmtest \
KEYCLOAK_URL=https://test.com \
poetry run uvicorn app.main:app --reload
Expand All @@ -24,4 +30,4 @@ There will be a route available at"

```
http://127.0.0.1:8000/config/keycloak
```
```
10 changes: 5 additions & 5 deletions app/areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def get_area(
"""Get an area by id"""

res = await client.get(
f"{config.SOIL_API_URL}/v1/areas/{area_id}",
f"{config.RIVER_API_URL}/v1/areas/{area_id}",
)

return res.json()
Expand All @@ -37,7 +37,7 @@ async def get_areas(
) -> Any:
"""Get all areas"""
res = await client.get(
f"{config.SOIL_API_URL}/v1/areas",
f"{config.RIVER_API_URL}/v1/areas",
params={"sort": sort, "range": range, "filter": filter},
)
response.headers["Access-Control-Expose-Headers"] = "Content-Range"
Expand All @@ -55,7 +55,7 @@ async def create_area(
"""Creates an area"""

res = await client.post(
f"{config.SOIL_API_URL}/v1/areas",
f"{config.RIVER_API_URL}/v1/areas",
json=area,
)

Expand All @@ -72,7 +72,7 @@ async def update_area(
""" "Updates an area by id"""

res = await client.put(
f"{config.SOIL_API_URL}/v1/areas/{area_id}", json=area
f"{config.RIVER_API_URL}/v1/areas/{area_id}", json=area
)

return res.json()
Expand All @@ -86,6 +86,6 @@ async def delete_area(
) -> None:
"""Delete an area by id"""

res = await client.delete(f"{config.SOIL_API_URL}/v1/areas/{area_id}")
res = await client.delete(f"{config.RIVER_API_URL}/v1/areas/{area_id}")

return res.json()
4 changes: 2 additions & 2 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class Config(BaseSettings):
# Keycloak UI settings
KEYCLOAK_CLIENT_ID: str

# SOIL-API settings
SOIL_API_URL: str # Full path to the Soil API (eg: http://soil-api-dev)
# RIVER-API settings
RIVER_API_URL: str # Full path to the Soil API (eg: http://river-api-dev)


@lru_cache()
Expand Down
10 changes: 5 additions & 5 deletions app/sensordata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def get_sensordata(
"""Get an individual sensordata record by id"""

res = await client.get(
f"{config.SOIL_API_URL}/v1/sensors/data/{sensordata_id}",
f"{config.RIVER_API_URL}/v1/sensors/data/{sensordata_id}",
)

return res.json()
Expand All @@ -37,7 +37,7 @@ async def get_all_sensordata(
"""Get all sensordata"""

res = await client.get(
f"{config.SOIL_API_URL}/v1/sensors/data",
f"{config.RIVER_API_URL}/v1/sensors/data",
params={"sort": sort, "range": range, "filter": filter},
)
response.headers["Access-Control-Expose-Headers"] = "Content-Range"
Expand All @@ -55,7 +55,7 @@ async def create_sensordata(
"""Creates an sensordata record"""

res = await client.post(
f"{config.SOIL_API_URL}/v1/sensors/data",
f"{config.RIVER_API_URL}/v1/sensors/data",
json=sensordata,
)

Expand All @@ -72,7 +72,7 @@ async def update_sensordata(
"""Updates an individual sensordata record by id"""

res = await client.put(
f"{config.SOIL_API_URL}/v1/sensors/data/{sensordata_id}",
f"{config.RIVER_API_URL}/v1/sensors/data/{sensordata_id}",
json=sensordata,
)

Expand All @@ -88,7 +88,7 @@ async def delete_sensor(
"""Delete an individual sensordata record by id"""

res = await client.delete(
f"{config.SOIL_API_URL}/v1/sensors/data/{sensordata_id}"
f"{config.RIVER_API_URL}/v1/sensors/data/{sensordata_id}"
)

return res.json()
12 changes: 6 additions & 6 deletions app/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def get_sensor(
"""Get a sensor by id"""

res = await client.get(
f"{config.SOIL_API_URL}/v1/sensors/{sensor_id}",
f"{config.RIVER_API_URL}/v1/sensors/{sensor_id}",
)

return res.json()
Expand All @@ -37,7 +37,7 @@ async def get_sensors(
"""Get all sensors"""

res = await client.get(
f"{config.SOIL_API_URL}/v1/sensors",
f"{config.RIVER_API_URL}/v1/sensors",
params={"sort": sort, "range": range, "filter": filter},
)
response.headers["Access-Control-Expose-Headers"] = "Content-Range"
Expand All @@ -55,7 +55,7 @@ async def create_sensor(
"""Creates an sensor"""

res = await client.post(
f"{config.SOIL_API_URL}/v1/sensors",
f"{config.RIVER_API_URL}/v1/sensors",
json=sensor,
)

Expand All @@ -71,7 +71,7 @@ async def create_many_sensors(
"""Creates an sensor"""

res = await client.post(
f"{config.SOIL_API_URL}/v1/sensors/many",
f"{config.RIVER_API_URL}/v1/sensors/many",
json=sensor,
)

Expand All @@ -88,7 +88,7 @@ async def update_sensor(
""" "Updates an sensor by id"""

res = await client.put(
f"{config.SOIL_API_URL}/v1/sensors/{sensor_id}", json=sensor
f"{config.RIVER_API_URL}/v1/sensors/{sensor_id}", json=sensor
)

return res.json()
Expand All @@ -102,6 +102,6 @@ async def delete_sensor(
) -> None:
"""Delete an sensor by id"""

res = await client.delete(f"{config.SOIL_API_URL}/v1/sensors/{sensor_id}")
res = await client.delete(f"{config.RIVER_API_URL}/v1/sensors/{sensor_id}")

return res.json()
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "sensormap-bff"
name = "astroriver-bff"
version = "0.1.0"
description = "The backend-for-frontend for sensormap"
description = "The backend-for-frontend for the astroriver interface"
authors = ["Evan Thomas <[email protected]>"]
readme = "README.md"

Expand Down

0 comments on commit 8d61152

Please sign in to comment.