Skip to content

Commit 364ee7e

Browse files
committed
docs(user-api): Document additions
1 parent ad8bdf6 commit 364ee7e

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

src/users/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ pub(crate) fn routes() -> Vec<Route> {
1515
routes![me]
1616
}
1717

18+
/// Get the authorized user's information
19+
///
20+
/// # Possible Responses
21+
///
22+
/// - `200 OK` with a serialized [`UserInfoResponse`] struct.
23+
/// - `401 Unauthorized`
24+
/// - If the session cookie is missing.
25+
/// - If the session is not found in the database.
26+
/// - `404 Not Found` if the user has no account links.
27+
/// - `500 Internal Server Error` if the user has no primary account link.
1828
#[get("/@me")]
1929
async fn me(conn: DbConn, session: Session) -> ApiResult<Json<UserInfoResponse>> {
2030
// Account links associated with the Discord ID

src/users/types.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
use rocket::serde::Serialize;
22
use std::collections::HashSet;
33

4+
/// The response for the `GET /@me` route.
45
#[derive(Serialize, Debug)]
56
#[serde(crate = "rocket::serde")]
6-
pub(crate) struct UserInfoResponse {
7-
pub(crate) user: User,
8-
pub(crate) linked_accounts: UserLinkedAccounts,
7+
pub(super) struct UserInfoResponse {
8+
pub(super) user: User,
9+
pub(super) linked_accounts: UserLinkedAccounts,
910
}
1011

12+
/// The user's primary account link.
1113
#[derive(Serialize, Debug)]
1214
#[serde(crate = "rocket::serde")]
13-
pub(crate) struct User {
14-
pub(crate) discord_uid: String,
15-
pub(crate) roblox_uid: String,
15+
pub(super) struct User {
16+
/// The user's Discord ID.
17+
pub(super) discord_uid: String,
18+
/// The user's Roblox ID.
19+
pub(super) roblox_uid: String,
1620
}
1721

22+
/// The user's account links (verification history).
1823
#[derive(Serialize, Default, Debug)]
1924
#[serde(crate = "rocket::serde")]
20-
pub(crate) struct UserLinkedAccounts {
21-
pub(crate) discord: HashSet<String>,
22-
pub(crate) roblox: HashSet<String>,
25+
pub(super) struct UserLinkedAccounts {
26+
/// All Discord IDs associated with the user.
27+
pub(super) discord: HashSet<String>,
28+
/// All Roblox IDs associated with the user.
29+
pub(super) roblox: HashSet<String>,
2330
}

0 commit comments

Comments
 (0)