1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! # SentryStr API
//!
//! REST API server for SentryStr event collection and querying.
//!
//! ## Quick Start
//!
//! ```rust
//! use sentrystr_api::create_app;
//! use sentrystr_collector::EventCollector;
//! use std::sync::Arc;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let relays = vec!["wss://relay.damus.io".to_string()];
//! let collector = Arc::new(EventCollector::new(relays).await?);
//!
//! let app = create_app(collector);
//!
//! let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
//! println!("SentryStr API server running on http://localhost:3000");
//!
//! axum::serve(listener, app).await?;
//! Ok(())
//! }
//! ```
//!
//! ## API Endpoints
//!
//! ### GET /events
//! Query events with optional filters:
//! ```bash
//! curl "http://localhost:3000/events?limit=10&level=error"
//! curl "http://localhost:3000/events?author=npub1...&since=2024-01-01T00:00:00Z"
//! ```
//!
//! ### GET /events/{author}
//! Get events by specific author:
//! ```bash
//! curl "http://localhost:3000/events/npub1abc123.../events"
//! ```
//!
//! ### GET /health
//! Health check endpoint:
//! ```bash
//! curl "http://localhost:3000/health"
//! ```
//!
//! ## With Tracing Integration
//!
//! ```rust
//! use sentrystr_api::create_app;
//! use sentrystr_collector::EventCollector;
//! use sentrystr_tracing::SentryStrTracingBuilder;
//! use tracing::{info, error};
//! use std::sync::Arc;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Setup tracing for the API server itself
//! SentryStrTracingBuilder::new()
//! .with_generated_keys_and_relays(vec!["wss://relay.damus.io".to_string()])
//! .init()
//! .await?;
//!
//! let relays = vec!["wss://relay.damus.io".to_string()];
//! let collector = Arc::new(EventCollector::new(relays).await?);
//! let app = create_app(collector);
//!
//! info!("Starting SentryStr API server");
//!
//! let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
//! axum::serve(listener, app).await?;
//!
//! Ok(())
//! }
//! ```
pub use create_app;
pub use *;
pub use *;
pub type Result<T> = Result;