Routes
interfaces.user.routes
Summary
User REST handlers — thin API entry points for the user resource, wired to openapi.yaml operationIds by the OpenAPI-first router. Current-user handlers read the authenticated principal from request.state and create the profile on first access.
Classes
Functions
create_user
async
Create a new user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request |
Request
|
Incoming HTTP request; carries app.state.db_resources. |
required |
body |
dict
|
User payload forwarded to the service. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UserDocument |
The created user. |
get_current_user
async
Get the profile of the authenticated user.
Reads the principal from request.state and creates the profile on first access when it does not exist yet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request |
Request
|
Incoming HTTP request; carries the authenticated user and app.state.db_resources. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UserDocument |
The current user's profile. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
401 when the request is not authenticated. |
get_user
async
Get a user by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request |
Request
|
Incoming HTTP request; carries app.state.db_resources. |
required |
id |
str
|
User id. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UserDocument |
The matching user. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
404 when no user matches the id. |
list_users
async
List users with pagination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request |
Request
|
Incoming HTTP request; carries app.state.db_resources. |
required |
skip |
int
|
Number of users to skip (offset). Defaults to 0. |
0
|
limit |
int
|
Maximum number of users to return. Defaults to 100. |
100
|
Returns:
| Type | Description |
|---|---|
|
list[UserDocument]: Matching users from UserCrudsService.search. |
update_current_user
async
Update the profile of the authenticated user.
Creates the profile on first access, then applies the update payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request |
Request
|
Incoming HTTP request; carries the authenticated user and app.state.db_resources. |
required |
body |
dict
|
Fields to update on the current user's profile. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UserDocument |
The updated profile. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
401 when the request is not authenticated. |