tangled
alpha
login
or
join now
eldridge.cam
/
cartography
0
fork
atom
Trading card city builder game?
0
fork
atom
overview
issues
pulls
pipelines
refactor docs
eldridge.cam
1 month ago
0b4c75c3
bf4d3c5e
verified
This commit was signed with the committer's
known signature
.
eldridge.cam
SSH Key Fingerprint:
SHA256:MAgO4sya2MgvdgUjSGKAO0lQ9X2HQp1Jb+x/Tpeeims=
+28
-29
2 changed files
expand all
collapse all
unified
split
packages
cartography
src
app.rs
main.rs
+18
-29
packages/cartography/src/app.rs
···
2
2
use crate::bus::Bus;
3
3
use axum::Router;
4
4
use kameo::actor::Spawn as _;
5
5
-
use utoipa::OpenApi as _;
6
5
7
6
#[derive(utoipa::OpenApi)]
8
7
#[openapi(
9
9
-
paths(
10
10
-
operations::get_banner,
11
11
-
operations::list_banners,
12
12
-
operations::pull_banner,
8
8
+
paths(
9
9
+
operations::get_banner,
10
10
+
operations::list_banners,
11
11
+
operations::pull_banner,
13
12
14
14
-
operations::list_card_types,
13
13
+
operations::list_card_types,
15
14
16
16
-
operations::list_fields,
17
17
-
),
18
18
-
components(
19
19
-
schemas(
20
20
-
crate::dto::AccountIdOrMe
21
21
-
)
22
22
-
),
23
23
-
tags(
24
24
-
(name = "Global", description = "Publicly available global data about the Cartography game."),
25
25
-
(name = "Player", description = "Player specific data; typically requires authorization."),
26
26
-
(name = "Game", description = "Actions with effects on gameplay."),
27
27
-
),
28
28
-
)]
15
15
+
operations::list_fields,
16
16
+
),
17
17
+
components(
18
18
+
schemas(
19
19
+
crate::dto::AccountIdOrMe
20
20
+
)
21
21
+
),
22
22
+
tags(
23
23
+
(name = "Global", description = "Publicly available global data about the Cartography game."),
24
24
+
(name = "Player", description = "Player specific data; typically requires authorization."),
25
25
+
(name = "Game", description = "Actions with effects on gameplay."),
26
26
+
),
27
27
+
)]
29
28
pub struct ApiDoc;
30
29
31
30
pub struct Config {
···
51
50
52
51
pub fn into_router(self) -> Router {
53
52
let bus = Bus::spawn(());
54
54
-
55
55
-
// let scalar_config = serde_json::json!({
56
56
-
// "url": "/api/openapi.json",
57
57
-
// "agent": scalar_api_reference::config::AgentOptions::disabled()
58
58
-
// });
59
53
60
54
axum::Router::new()
61
55
.route(
···
79
73
axum::routing::get(operations::list_fields),
80
74
)
81
75
.route("/play/ws", axum::routing::any(ws::v1))
82
82
-
.route(
83
83
-
"/api/openapi.json",
84
84
-
axum::routing::get(axum::response::Json(ApiDoc::openapi())),
85
85
-
)
86
86
-
// .merge(scalar_api_reference::axum::router("/docs", &scalar_config)) // TODO: waiting on scalar_api_reference to re-publish
87
76
.layer(axum::middleware::from_fn(middleware::authorization::trust))
88
77
.layer(axum::Extension(bus))
89
78
.layer(axum::Extension(self.pool))
+10
packages/cartography/src/main.rs
···
43
43
.parse()
44
44
.expect("PORT must be a valid u16");
45
45
46
46
+
// let scalar_config = serde_json::json!({
47
47
+
// "url": "/api/openapi.json",
48
48
+
// "agent": scalar_api_reference::config::AgentOptions::disabled()
49
49
+
// });
50
50
+
46
51
let app = app::new()
47
52
.await?
53
53
+
// .merge(scalar_api_reference::axum::router("/docs", &scalar_config)) // TODO: waiting on scalar_api_reference to re-publish
54
54
+
.route(
55
55
+
"/api/openapi.json",
56
56
+
axum::routing::get(axum::response::Json(app::ApiDoc::openapi())),
57
57
+
)
48
58
.layer(tower_http::trace::TraceLayer::new_for_http());
49
59
50
60
let listener = tokio::net::TcpListener::bind((host, port)).await?;