mirror of
https://github.com/logos-blockchain/logos-blockchain-block-explorer-template.git
synced 2026-05-22 01:09:34 +00:00
Merge pull request #17 from logos-blockchain/sqlite-env-path
chore: Set sqlite db path via env
This commit is contained in:
commit
93d8ec76f4
@ -120,6 +120,8 @@ NBE_NODE_API_PROTOCOL=http # Only used if NODE_API=http
|
||||
|
||||
NBE_HOST=0.0.0.0 # Block Explorer's listening host
|
||||
NBE_PORT=8000 # Block Explorer's listening port
|
||||
|
||||
NBE_DATABASE_URL=sqlite:///sqlite.db # Database connection URL
|
||||
```
|
||||
If running the Block Explorer with Docker, these can be overridden.
|
||||
|
||||
|
||||
@ -31,6 +31,8 @@ class NBESettings(BaseSettings):
|
||||
node_api_protocol: str = Field(alias="NBE_NODE_API_PROTOCOL", default="http")
|
||||
node_api_auth: Optional[Authentication] = Field(alias="NBE_NODE_API_AUTH", default=None)
|
||||
|
||||
database_url: str = Field(alias="NBE_DATABASE_URL", default=f"sqlite:///{DIR_REPO}/sqlite.db")
|
||||
|
||||
@field_validator("node_api_auth", mode="before")
|
||||
@classmethod
|
||||
def parse_auth(cls, value: str) -> Optional[Authentication]:
|
||||
|
||||
@ -95,7 +95,7 @@ async def node_lifespan(app: "NBE") -> AsyncGenerator[None]:
|
||||
app.state.node_manager = build_node_manager(app.settings)
|
||||
app.state.node_api = build_node_api(app.settings)
|
||||
|
||||
db_client = SqliteClient()
|
||||
db_client = SqliteClient(sqlite_db_path=app.settings.database_url)
|
||||
app.state.db_client = db_client
|
||||
app.state.block_repository = BlockRepository(db_client)
|
||||
app.state.transaction_repository = TransactionRepository(db_client)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user