|
6 | 6 | import os
|
7 | 7 |
|
8 | 8 | from mangum import Mangum
|
| 9 | +from stac_fastapi.pgstac.app import app |
| 10 | +from stac_fastapi.pgstac.config import PostgresSettings |
| 11 | +from stac_fastapi.pgstac.db import close_db_connection, connect_to_db |
9 | 12 | from utils import get_secret_dict
|
10 | 13 |
|
11 | 14 | secret = get_secret_dict(secret_arn_env_var="PGSTAC_SECRET_ARN")
|
12 |
| - |
13 |
| -os.environ.update( |
14 |
| - { |
15 |
| - "postgres_host_reader": secret["host"], |
16 |
| - "postgres_host_writer": secret["host"], |
17 |
| - "postgres_dbname": secret["dbname"], |
18 |
| - "postgres_user": secret["username"], |
19 |
| - "postgres_pass": secret["password"], |
20 |
| - "postgres_port": str(secret["port"]), |
21 |
| - } |
| 15 | +postgres_settings = PostgresSettings( |
| 16 | + postgres_host_reader=secret["host"], |
| 17 | + postgres_host_writer=secret["host"], |
| 18 | + postgres_dbname=secret["dbname"], |
| 19 | + postgres_user=secret["username"], |
| 20 | + postgres_pass=secret["password"], |
| 21 | + postgres_port=int(secret["port"]), |
22 | 22 | )
|
23 | 23 |
|
24 |
| -from stac_fastapi.pgstac.app import app |
25 |
| -from stac_fastapi.pgstac.db import close_db_connection, connect_to_db |
26 |
| - |
27 | 24 |
|
28 | 25 | @app.on_event("startup")
|
29 | 26 | async def startup_event():
|
30 | 27 | """Connect to database on startup."""
|
31 | 28 | print("Setting up DB connection...")
|
32 |
| - await connect_to_db(app) |
| 29 | + await connect_to_db(app, postgres_settings=postgres_settings) |
33 | 30 | print("DB connection setup.")
|
34 | 31 |
|
35 | 32 |
|
|
0 commit comments