Skip to main content

systemprompt_api/repository/
mod.rs

1//! Composition modules that construct-and-store repository bundles and
2//! single repositories for router state.
3//!
4//! Copyright (c) systemprompt.io — Business Source License 1.1.
5//! See <https://systemprompt.io> for licensing details.
6
7pub mod gateway;
8
9pub use gateway::GatewayRepositories;
10
11use std::sync::Arc;
12use systemprompt_database::DbPool;
13
14pub fn banned_ips(
15    db: &DbPool,
16) -> Result<Arc<systemprompt_users::BannedIpRepository>, systemprompt_users::UserError> {
17    Ok(Arc::new(systemprompt_users::BannedIpRepository::new(db)?))
18}
19
20pub fn tool_usage(
21    db: &DbPool,
22) -> Result<Arc<systemprompt_mcp::repository::ToolUsageRepository>, systemprompt_mcp::McpDomainError>
23{
24    Ok(Arc::new(
25        systemprompt_mcp::repository::ToolUsageRepository::new(db)?,
26    ))
27}
28
29pub fn proxy_identities(
30    db: &DbPool,
31) -> Result<
32    Arc<systemprompt_mcp::repository::McpProxyIdentityRepository>,
33    systemprompt_mcp::McpDomainError,
34> {
35    Ok(Arc::new(
36        systemprompt_mcp::repository::McpProxyIdentityRepository::new(db)?,
37    ))
38}
39
40pub fn user_rate_limit_buckets(
41    db: &DbPool,
42) -> Result<Arc<systemprompt_users::UserRateLimitBucketRepository>, systemprompt_users::UserError> {
43    Ok(Arc::new(
44        systemprompt_users::UserRateLimitBucketRepository::new(db)?,
45    ))
46}