feat: OAuth implementation with Discord
CI / tests (push) Successful in 10m39s
CI / tests (pull_request) Successful in 11m17s

This commit separates the core features of GéJDR from the backend as
these will also be used by the bot in the future.

This commit also updates the dependencies of the project. It also
removes the dependency lettre as well as the mailpit docker service
for developers as it appears clearer this project won’t send emails
anytime soon.

The publication of a docker image is also postponed until later.
This commit is contained in:
2024-08-10 11:06:18 +02:00
parent 2013d04cf7
commit aac70e4131
49 changed files with 2699 additions and 720 deletions
+46
View File
@@ -0,0 +1,46 @@
use poem::Result;
use poem_openapi::{payload::Json, ApiResponse, Object, OpenApi};
use crate::settings::Settings;
use super::ApiCategory;
#[derive(Object, Debug, Clone, serde::Serialize, serde::Deserialize)]
struct Meta {
version: String,
}
impl From<poem::web::Data<&Settings>> for Meta {
fn from(value: poem::web::Data<&Settings>) -> Self {
let version = value.application.version.clone();
Self { version }
}
}
#[derive(ApiResponse)]
enum VersionResponse {
#[oai(status = 200)]
Version(Json<Meta>),
}
pub struct VersionApi;
#[OpenApi(prefix_path = "/v1/api/version", tag = "ApiCategory::Version")]
impl VersionApi {
#[oai(path = "/", method = "get")]
async fn version(&self, settings: poem::web::Data<&Settings>) -> Result<VersionResponse> {
tracing::event!(target: "gege-jdr-backend", tracing::Level::DEBUG, "Accessing version endpoint.");
Ok(VersionResponse::Version(Json(settings.into())))
}
}
#[tokio::test]
async fn version_works() {
let app = crate::get_test_app(None).await;
let cli = poem::test::TestClient::new(app);
let resp = cli.get("/v1/api/version").send().await;
resp.assert_status_is_ok();
let json = resp.json().await;
let json_value = json.value();
json_value.object().get("version").assert_not_null();
}