Skip to content

Commit

Permalink
Add readme with instructions
Browse files Browse the repository at this point in the history
Signed-off-by: nain-F49FF806 <[email protected]>
  • Loading branch information
nain-F49FF806 committed Sep 13, 2023
1 parent aadf0d5 commit 4adc7dd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
46 changes: 46 additions & 0 deletions mediator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Aries VCX Mediator

A mediator service for Aries Agents.

**Status**: Dev

## Build

This project depends on `aries-vcx` and is tightly integrated to work with it.
As such we expect this `mediator` module to be in a subdirectory of aries-vcx repo.
You may transplant it, but expect to change the `Cargo.toml` and adjust the dependencies on aries modules manually.

When ready it's simple to build.

```bash
# Dev environment build
cargo build
```

## Usage

You can run and test the produced binary using cargo.

```bash
cargo run
```

### Configurable Options

Currently the mediator reads the following environment variables.

```yaml
`ENDPOINT_ROOT`:
- **Description**: This is the address at which the mediator will listen for connections.
- **Default**: "127.0.0.1:8005"
- **Usage**: `ENDPOINT_ROOT=127.0.0.1:3000 cargo run`
```

## API

Currently exposed endpoints.

```yaml
`/register`:
- **Description** : Shows an Aries Out Of Band (OOB) invitation which can be used to connect to the mediator using a conformant Aries Agent.
```
2 changes: 1 addition & 1 deletion mediator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async fn main() {
println!("Hello, world!");
load_dot_env();
setup_logging();
let endpoint_root = std::env::var("ENDPOINT_ROOT").unwrap_or("0.0.0.0:8005".into());
let endpoint_root = std::env::var("ENDPOINT_ROOT").unwrap_or("127.0.0.1:8005".into());
info!("Endpoint root address {}", endpoint_root);
let app_router = mediator::routes::build_router(&endpoint_root).await;
axum::Server::bind(
Expand Down
7 changes: 6 additions & 1 deletion mediator/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use aries_vcx_core::wallet::indy::IndySdkWallet;
use axum::extract::State;
use axum::response::Html;
use axum::routing::{get, post};
use axum::routing::get;
use axum::Router;
use axum_macros::debug_handler;

Expand All @@ -27,13 +27,18 @@ pub async fn oob_invite_qr(State(agent): State<Arc<Agent<IndySdkWallet>>>) -> Ht
))
}

pub async fn readme() -> Html<String> {
Html("<p>Please refer to the API section of <a>readme</a> for usage. Thanks. </p>".into())
}

pub async fn build_router(endpoint_root: &str) -> Router {
let mut agent = Agent::new_demo_agent().await.unwrap();
agent
.init_service(vec![], format!("http://{endpoint_root}").parse().unwrap())
.await
.unwrap();
Router::default()
.route("/", get(readme))
.route("/register", get(oob_invite_qr))
.layer(tower_http::catch_panic::CatchPanicLayer::new())
.with_state(Arc::new(agent))
Expand Down

0 comments on commit 4adc7dd

Please sign in to comment.