-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding in auth and server init
- Loading branch information
Showing
14 changed files
with
324 additions
and
110 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,12 +1,32 @@ | ||
use crate::db; | ||
use tonic::Status; | ||
use crate::{db, jwt::JwtVerifier, middleware::AuthLayer, Context}; | ||
use std::net::SocketAddr; | ||
use tonic::{transport::Server, Status}; | ||
|
||
pub mod app; | ||
pub mod charts; | ||
pub mod user; | ||
mod app; | ||
mod charts; | ||
mod user; | ||
|
||
use app::RatingService; | ||
use charts::ChartService; | ||
use user::UserService; | ||
|
||
impl From<db::Error> for Status { | ||
fn from(value: db::Error) -> Self { | ||
Status::internal(value.to_string()) | ||
} | ||
} | ||
|
||
pub async fn run_server(ctx: Context) -> Result<(), Box<dyn std::error::Error>> { | ||
let verifier = JwtVerifier::from_secret(&ctx.config.jwt_secret)?; | ||
let addr: SocketAddr = ctx.config.socket().parse()?; | ||
|
||
Server::builder() | ||
.layer(AuthLayer::new(verifier)) | ||
.add_service(RatingService::new_server()) | ||
.add_service(ChartService::new_server()) | ||
.add_service(UserService::new_server(ctx)) | ||
.serve(addr) | ||
.await?; | ||
|
||
Ok(()) | ||
} |
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
Oops, something went wrong.