-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::sync::Arc; | ||
|
||
use poem::web::{Data, Path}; | ||
use poem_openapi::{payload::Json, OpenApi}; | ||
|
||
use crate::{models::user_data::{User, UserEntry}, state::AppState}; | ||
|
||
pub struct ApiUserById; | ||
|
||
#[OpenApi] | ||
impl ApiUserById { | ||
#[oai(path = "/user/:id", method = "get")] | ||
pub async fn user(&self, state: Data<&Arc<AppState>>, id: Path<i32>) -> Json<User> { | ||
let user = UserEntry::get_by_id(id.0, &state.database) | ||
.await | ||
.unwrap(); | ||
|
||
Json(user.into()) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useHttp } from './core'; | ||
|
||
export type ApiUserByIdResponse = { | ||
id: number; | ||
oauth_sub: string; | ||
name: string; | ||
picture: string; | ||
// oauth_data: { | ||
// sub: string; | ||
// name: string; | ||
// given_name: string; | ||
// family_name: string; | ||
// middle_name: null; | ||
// nickname: null; | ||
// preferred_username: null; | ||
// profile: null; | ||
// picture: string; | ||
// website: null; | ||
// email: string; | ||
// email_verified: boolean; | ||
// gender: null; | ||
// birthdate: null; | ||
// zoneinfo: null; | ||
// locale: null; | ||
// phone_number: null; | ||
// phone_number_verified: boolean; | ||
// address: null; | ||
// updated_at: null; | ||
// }; | ||
}; | ||
|
||
export const useApiUserById = (user_id: string) => | ||
useHttp<ApiUserByIdResponse>(`/api/user/${user_id}`); |
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