-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Automatically generate OpenAPI schema * Properly document fields * Expose API docs
- Loading branch information
Showing
9 changed files
with
803 additions
and
70 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,44 @@ | ||
use std::{env, net::SocketAddr}; | ||
|
||
use axum::{Extension, Server}; | ||
use aide::openapi::{Info, License, OpenApi}; | ||
use axum::Extension; | ||
use redis::aio::ConnectionManager; | ||
use tokio::net::TcpListener; | ||
|
||
use crate::routes; | ||
|
||
pub async fn start(redis: ConnectionManager) { | ||
let app = routes::handler().layer(Extension(redis)); | ||
let mut openapi = OpenApi { | ||
info: Info { | ||
title: "Wallet Bridge".to_string(), | ||
summary: Some( | ||
"An end-to-end encrypted bridge for communicating with World App.".to_string(), | ||
), | ||
license: Some(License { | ||
name: "MIT".to_string(), | ||
identifier: Some("MIT".to_string()), | ||
..Default::default() | ||
}), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}; | ||
|
||
let app = routes::handler() | ||
.finish_api(&mut openapi) | ||
.layer(Extension(redis)) | ||
.layer(Extension(openapi)); | ||
|
||
let address = SocketAddr::from(( | ||
[0, 0, 0, 0], | ||
env::var("PORT").map_or(8000, |p| p.parse().unwrap()), | ||
)); | ||
let listener = TcpListener::bind(&address) | ||
.await | ||
.expect("Failed to bind address"); | ||
|
||
println!("🪩 World Bridge started on http://{address}"); | ||
Server::bind(&address) | ||
.serve(app.into_make_service()) | ||
axum::serve(listener, app.into_make_service()) | ||
.await | ||
.expect("Failed to start server"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters