### Start Nexus API Server from Path Source: https://github.com/pubky/pubky-nexus/blob/main/nexus-webapi/README.md Start the Nexus API server by loading configuration from a specified file path. ```rust use nexus_watcher::builder::NexusWatcher; use std::path::PathBuf; #[tokio::main] async fn main() -> Result<(), Box> { NexusApi::start_from_path(PathBuf::from("path/to/config/folder")).await?; Ok(()) } ``` -------------------------------- ### Run Nexus Watcher Source: https://github.com/pubky/pubky-nexus/blob/main/examples/README.md Starts the Nexus watcher service. Requires the `watcher_example` binary. ```bash cargo run --bin watcher_example ``` -------------------------------- ### Set Up Docker Environment for Nexus Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Navigate to the docker directory, copy the environment sample, and start the Docker Compose services to set up the development environment. ```bash cd docker cp .env-sample .env docker compose up -d ``` -------------------------------- ### Run Nexus Watcher with Default Configuration Source: https://github.com/pubky/pubky-nexus/blob/main/nexus-watcher/README.md Starts the Nexus Watcher service using its default configuration. This is the simplest way to get the watcher running. ```rust use nexus_watcher::service::NexusWatcher; #[tokio::main] async fn main() -> Result<(), Box> { NexusWatcher::builder().run().await } ``` -------------------------------- ### Start Nexus API Server Source: https://github.com/pubky/pubky-nexus/blob/main/nexus-webapi/README.md Build and run the Nexus API server using the default configuration. ```rust use nexus_webapi::builder::NexusApi; #[tokio::main] async fn main() -> Result<(), Box> { // Build and run the Nexus API server NexusApi::builder().run().await?; Ok(()) } ``` -------------------------------- ### Run Nexus API Server Source: https://github.com/pubky/pubky-nexus/blob/main/examples/README.md Starts the Nexus API server. It serves on localhost:8081 by default. Requires the `api_example` binary. ```bash cargo run --bin api_example ``` -------------------------------- ### Initialize Database Connectors Source: https://github.com/pubky/pubky-nexus/blob/main/nexus-common/README.md Shows how to initialize Neo4j and Redis connectors using their respective configurations and then retrieve active connections. This setup is typically done once per application. Requires `tokio` for async operations. ```rust use nexus_common::db::{Neo4jConnector, RedisConnector, get_neo4j_graph, get_redis_conn}; use nexus_common::db::Neo4JConfig; use nexus_common::types::DynError; #[tokio::main] async fn main() -> Result<(), DynError> { // Initialize connectors (once per app) Neo4jConnector::init(Neo4JConfig::default()).await?; RedisConnector::init("redis://127.0.0.1:6379").await?; // Use helper functions let graph = get_neo4j_graph()?; let mut redis_conn = get_redis_conn().await?; Ok(()) } ``` -------------------------------- ### Run Nexus Watcher with Configuration File Source: https://github.com/pubky/pubky-nexus/blob/main/nexus-watcher/README.md Starts the Nexus Watcher service by loading configuration from a specified file path. Use this when you need to customize settings via a configuration file. ```rust use nexus_watcher::service::NexusWatcher; use std::path::PathBuf; #[tokio::main] async fn main() -> Result<(), Box> { NexusWatcher::start_from_path(PathBuf::from("path/to/config/folder")).await?; Ok(()) } ``` -------------------------------- ### Run Nexus API Service Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Start the Nexus API service using Cargo. This service exposes the API endpoints for interacting with Nexus. ```bash cargo run -p nexusd -- api ``` -------------------------------- ### Run Nexus Watcher Service Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Start the Nexus watcher service using Cargo. This service is responsible for monitoring and reacting to changes. ```bash cargo run -p nexusd -- watcher ``` -------------------------------- ### Cache-First Entity Retrieval Source: https://github.com/pubky/pubky-nexus/blob/main/nexus-common/README.md Demonstrates retrieving a `UserDetails` entity using a cache-first strategy. It first attempts to fetch from Redis and falls back to Neo4j if the entity is not found in the cache. Requires `tokio` for async operations and `StackManager` setup. ```rust use nexus_common::models::user::UserDetails; use nexus_common::types::DynError; use nexus_common::{StackManager, StackConfig}; #[tokio::main] async fn main() -> Result<(), DynError> { StackManager::setup(&StackConfig::default()).await?; // Cache-first: Redis -> Neo4j fallback if let Some(user) = UserDetails::get_by_id("some_user_id").await? { println!("User: {}", user.name); } Ok(()) } ``` -------------------------------- ### Run Nexus Database Clear Command Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Execute a command to clear the Nexus database using Cargo. This is often useful before starting the watcher service to ensure a clean state. ```bash cargo run -p nexusd -- db clear ``` -------------------------------- ### Load Daemon Configuration Source: https://github.com/pubky/pubky-nexus/blob/main/nexus-common/README.md Demonstrates loading a DaemonConfig from a file, expanding the home directory path, and printing the loaded configuration. Requires `tokio` for async operations. ```rust use nexus_common::config::{ConfigLoader, DaemonConfig}; use std::path::Path; use nexus_common::types::DynError; #[tokio::main] async fn main() -> Result<(), DynError> { let cfg: DaemonConfig = DaemonConfig::read_config_file( config::expand_home_dir("~/.pubky-nexus".into()) ).await?; println!("Loaded config: {:#?}", cfg); Ok(()) } ``` -------------------------------- ### Configure Nexus Watcher Source: https://github.com/pubky/pubky-nexus/blob/main/examples/README.md Runs the Nexus watcher service with a custom configuration file. Expects `watcher-config.toml` at the specified path. If the file is not found, a default `config.toml` will be created. ```bash cargo run --bin watcher_example -- --config=test_path ``` -------------------------------- ### Load Mock Data for Tests Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Use this command to load mock data into Neo4j and Redis before running tests. Ensure Docker or Podman is configured. ```bash # If you're using podman instead of docker, set this env variable before importing mock data # export CONTAINER_RUNTIME=podman cargo run -p nexusd -- db mock ``` -------------------------------- ### Configure Nexus API Server Source: https://github.com/pubky/pubky-nexus/blob/main/examples/README.md Runs the Nexus API server with a custom configuration file. Expects `api-config.toml` at the specified path. If the file is not found, a default `config.toml` will be created. ```bash cargo run --bin api_example -- --config=test_path ``` -------------------------------- ### Run Benchmarks Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Execute performance benchmarks for the nexus-webapi crate. You can run all benchmarks or target a specific endpoint. ```bash # cargo bench -p nexus-webapi [--bench ] cargo bench -p nexus-webapi ``` ```bash # or if you want specific endpoint cargo bench -p nexus-webapi --bench user ``` -------------------------------- ### Create New Migration with CLI Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Use this command to generate a new migration file. The migration name will be appended with a timestamp. ```bash cargo run -p nexusd -- db migration new TagCountsReset ``` -------------------------------- ### Run Pending Migrations with CLI Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Execute this command to run all pending database migrations. The manager handles the order and progression through phases. ```bash cargo run -p nexusd db migration run ``` -------------------------------- ### Run Nexus Service with Default Configuration Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Execute the Nexus service using Cargo. This command runs the service with default configuration values, which are typically loaded from $HOME/.pubky-nexus/config.toml. ```bash cargo run -p nexusd ``` -------------------------------- ### Add Nexus API Dependency Source: https://github.com/pubky/pubky-nexus/blob/main/nexus-webapi/README.md Add the nexus-webapi crate to your project's Cargo.toml file. ```bash cargo add nexus-webapi ``` -------------------------------- ### Run Nexus Service with Custom Configuration Directory Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Run the Nexus service using Cargo, specifying a custom directory for the configuration file. This allows for flexible configuration management. ```bash cargo run -p nexusd -- --config-dir="custom/config/folder" ``` -------------------------------- ### Execute Neo4J Graph Database Scripts Source: https://github.com/pubky/pubky-nexus/blob/main/docker/test-graph/readme.md Run Cypher queries within the Neo4J Docker container to initialize or update the graph database. Ensure the .env file is configured from .env-sample before execution. ```bash docker exec neo4j bash /db-graph/run-queries.sh ``` -------------------------------- ### Run All Tests Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Execute all tests for the nexus-common, nexus-webapi, and nexus-watcher crates. The --no-fail-fast flag ensures all tests run even if some fail. ```bash cargo nextest run -p nexus-common --no-fail-fast ``` ```bash cargo nextest run -p nexus-webapi --no-fail-fast ``` ```bash # nexus-watcher tests need the Postgres Connection URL as env variable, adjust it as needed # export TEST_PUBKY_CONNECTION_STRING=postgres://test_user:test_pass@localhost:5432/postgres?pubky-test=true cargo nextest run -p nexus-watcher --no-fail-fast ``` -------------------------------- ### Run Specific Tests Source: https://github.com/pubky/pubky-nexus/blob/main/README.md Filter and run tests for a specific feature, such as 'files::create' within the nexus-watcher crate. Use --no-fail-fast to run all matching tests. ```bash cargo nextest run -p nexus-watcher files::create --no-fail-fast ``` -------------------------------- ### Add nexus-common to Cargo.toml Source: https://github.com/pubky/pubky-nexus/blob/main/nexus-common/README.md Include the nexus-common crate in your project's dependencies by adding it to your Cargo.toml file. ```bash cargo add nexus-common ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.