- Use c.Get("user").(database.Users) instead of c.Get("user_id").(string)
- Extract userUUID from user.ID.Bytes ([16]byte)
- Properly convert to pgtype.UUID for service layer
- Remove unnecessary uuid.Parse call
This fixes 500 Internal Server Error when creating libraries via API.
The JWT middleware sets user as database.Users struct, not string.
Related to Bruno Create Library request testing.
67 lines
1.4 KiB
Plaintext
67 lines
1.4 KiB
Plaintext
meta {
|
|
name: Create Library
|
|
type: http
|
|
seq: 1
|
|
}
|
|
|
|
post {
|
|
url: {{base_url}}/api/libraries
|
|
body: json
|
|
auth: inherit
|
|
}
|
|
|
|
headers {
|
|
Content-Type: application/json
|
|
}
|
|
|
|
body:json {
|
|
{
|
|
"name": "My Ebook Library",
|
|
"description": "A collection of technical books and novels",
|
|
"type": "ebooks"
|
|
}
|
|
}
|
|
|
|
settings {
|
|
encodeUrl: true
|
|
timeout: 0
|
|
}
|
|
|
|
docs {
|
|
## Create Library
|
|
|
|
Creates a new library for organizing media items.
|
|
|
|
**Method:** POST
|
|
|
|
**Endpoint:** /api/libraries
|
|
|
|
**Authentication:** Required (Bearer token)
|
|
|
|
**Request Body:**
|
|
- `name` (string, required): Library name
|
|
- `description` (string, optional): Library description
|
|
- `type` (string, required): Library type
|
|
- `"ebooks"`: Electronic books
|
|
- `"audiobooks"`: Audio books
|
|
- `"videos"`: Video content
|
|
- `"other"`: Other media types
|
|
|
|
**Response:** Library object
|
|
- `id` (string): Library UUID
|
|
- `name` (string): Library name
|
|
- `description` (string, optional): Library description
|
|
- `type` (string): Library type
|
|
- `is_visible` (boolean): Library visibility status
|
|
- `created_at` (string): Creation timestamp
|
|
- `updated_at` (string): Last update timestamp
|
|
|
|
**Status Codes:**
|
|
- 201: Library created successfully
|
|
- 400: Invalid request data
|
|
- 401: Unauthorized
|
|
- 403: Forbidden (insufficient permissions)
|
|
- 409: Library name already exists
|
|
- 500: Internal server error
|
|
}
|