Files
nym/nym-statistics-api/src/http/state.rs
T
Simon Wicky b69c2e1e94 Nym Statistics API (#5800)
* move stats types from vpn-client to here

* base stats api

* change storage schema

* add link to nymAPI for whitelisting

* remove outdated comment

* more comments update

* example of chrono vs time

* Add build.rs
- exports DATABASE_URL so cargo check works
- exports SQLX_OFFLINE for CI
- added pg_up.sh which spawns PG container
  - required for cargo sqlx prepare

* fixes time vs chrono issue and cleaner build with docker

* add correct swagger types, with feature locking where relevant

* apply dynco suggestions

---------

Co-authored-by: dynco-nym <173912580+dynco-nym@users.noreply.github.com>
2025-05-28 10:23:11 +02:00

25 lines
597 B
Rust

use crate::{network_view::NetworkView, storage::StatisticsStorage};
#[derive(Debug, Clone)]
pub(crate) struct AppState {
storage_manager: StatisticsStorage,
network_view: NetworkView,
}
impl AppState {
pub(crate) async fn new(storage_manager: StatisticsStorage, network_view: NetworkView) -> Self {
Self {
storage_manager,
network_view,
}
}
pub(crate) fn storage(&mut self) -> &mut StatisticsStorage {
&mut self.storage_manager
}
pub(crate) fn network_view(&self) -> &NetworkView {
&self.network_view
}
}