docs: write home and users endpoint sections
This commit is contained in:
+112
-2
@@ -87,11 +87,121 @@ No `Retry-After` header is currently returned. Clients should back off and retry
|
||||
|
||||
### 4.1 Home
|
||||
|
||||
_TODO_
|
||||
#### `GET /`
|
||||
|
||||
Health check. No authentication required.
|
||||
|
||||
**Response:** `200 OK`
|
||||
```
|
||||
Welcome
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 4.2 Users
|
||||
|
||||
_TODO_
|
||||
Base path: `/api/users`
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/users/createUser` — Register a user
|
||||
|
||||
**Auth required:** No
|
||||
|
||||
**Request body:**
|
||||
```json
|
||||
{
|
||||
"username": "alice",
|
||||
"googleId": "118400012345678901234"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Constraints |
|
||||
|-------|------|-------------|
|
||||
| `username` | String | Required. 3–30 chars. Pattern: `^[a-zA-Z0-9_.\-]+$` |
|
||||
| `googleId` | String | Required. Non-blank. Must match the JWT `sub` from Google. |
|
||||
|
||||
**Success response:** `200 OK` — returns the created [AppUser](#appuser) object.
|
||||
|
||||
**Error responses:**
|
||||
| Status | Condition |
|
||||
|--------|-----------|
|
||||
| 400 | Validation failure (field errors returned as `{"fieldName": "message"}`) |
|
||||
| 409 | `username` already taken |
|
||||
|
||||
---
|
||||
|
||||
#### `GET /api/users` — Get user by ID
|
||||
|
||||
**Auth required:** Yes
|
||||
|
||||
**Query params:**
|
||||
| Param | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `id` | Long | Yes | Database ID of the user |
|
||||
|
||||
**Success response:** `200 OK` — returns [AppUser](#appuser).
|
||||
|
||||
**Error responses:**
|
||||
| Status | Condition |
|
||||
|--------|-----------|
|
||||
| 404 | No user found for `id` |
|
||||
|
||||
---
|
||||
|
||||
#### `GET /api/users/byName` — Get user by username
|
||||
|
||||
**Auth required:** No
|
||||
|
||||
**Query params:**
|
||||
| Param | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `username` | String | Yes | Exact username (case-sensitive) |
|
||||
|
||||
**Success response:** `200 OK` — returns [AppUser](#appuser).
|
||||
|
||||
**Error responses:**
|
||||
| Status | Condition |
|
||||
|--------|-----------|
|
||||
| 404 | No user found for `username` |
|
||||
|
||||
---
|
||||
|
||||
#### `GET /api/users/byGoogleId` — Get user by Google ID
|
||||
|
||||
**Auth required:** Yes
|
||||
|
||||
**Query params:**
|
||||
| Param | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `id` | String | Yes | Google `sub` claim |
|
||||
|
||||
**Success response:** `200 OK` — returns [AppUser](#appuser).
|
||||
|
||||
**Error responses:**
|
||||
| Status | Condition |
|
||||
|--------|-----------|
|
||||
| 404 | No user found for that Google ID |
|
||||
|
||||
---
|
||||
|
||||
#### `DELETE /api/users` — Delete a user
|
||||
|
||||
**Auth required:** Yes
|
||||
|
||||
**Query params:**
|
||||
| Param | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `id` | Long | Yes | Database ID of the user to delete |
|
||||
|
||||
**Success response:** `200 OK` — returns the deleted [AppUser](#appuser).
|
||||
|
||||
**Error responses:**
|
||||
| Status | Condition |
|
||||
|--------|-----------|
|
||||
| 404 | No user found for `id` |
|
||||
|
||||
---
|
||||
|
||||
### 4.3 Expense Lists
|
||||
|
||||
|
||||
Reference in New Issue
Block a user