feat: Add admin ebook CRUD operations to Bruno collection
- Add POST /api/ebooks for creating new ebook entries - Add PUT /api/ebooks/:id for updating existing ebook metadata - Add DELETE /api/ebooks/:id for deleting ebooks from database - Include complete request/response examples with all metadata fields - Support file path, metadata, and publication information updates
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
meta {
|
||||
name: Create Ebook
|
||||
type: http
|
||||
seq: 8
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{base_url}}/api/ebooks
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"title": "Sample Ebook Title",
|
||||
"author": "Author Name",
|
||||
"isbn": "978-0123456789",
|
||||
"description": "A sample ebook description",
|
||||
"file_path": "/path/to/ebook.epub",
|
||||
"file_size": 1048576,
|
||||
"mime_type": "application/epub+zip",
|
||||
"cover_image_path": "/path/to/cover.jpg",
|
||||
"series": "Sample Series",
|
||||
"series_number": 1,
|
||||
"tags": "fiction,adventure",
|
||||
"asin": "B00EXAMPLE",
|
||||
"date_published": "2023-01-15",
|
||||
"publisher": "Sample Publisher",
|
||||
"contributors": "Contributor Name"
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Create Ebook
|
||||
|
||||
Creates a new ebook entry in the database.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/ebooks
|
||||
|
||||
**Authentication:** Required (Admin only)
|
||||
|
||||
**Request Body:** JSON object with:
|
||||
- `title` (string, required): Ebook title (1-500 characters)
|
||||
- `author` (string, optional): Author name
|
||||
- `isbn` (string, optional): ISBN number
|
||||
- `description` (string, optional): Ebook description
|
||||
- `file_path` (string, required): Path to ebook file
|
||||
- `file_size` (integer, required): File size in bytes
|
||||
- `mime_type` (string, required): MIME type of ebook
|
||||
- `cover_image_path` (string, optional): Path to cover image
|
||||
- `series` (string, optional): Series name
|
||||
- `series_number` (integer, optional): Number in series
|
||||
- `tags` (string, optional): Comma-separated tags
|
||||
- `asin` (string, optional): Amazon ASIN
|
||||
- `date_published` (string, optional): Publication date (YYYY-MM-DD)
|
||||
- `publisher` (string, optional): Publisher name
|
||||
- `contributors` (string, optional): Contributors list
|
||||
|
||||
**Response:** Complete ebook object with all fields
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Ebook created successfully
|
||||
- 400: Bad request (invalid data)
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (admin access required)
|
||||
- 500: Internal server error
|
||||
|
||||
**Features:**
|
||||
- Admin-only endpoint for creating ebooks
|
||||
- Full validation of required fields
|
||||
- Supports all ebook metadata fields
|
||||
- Associates ebook with creating admin user
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
meta {
|
||||
name: Delete Ebook
|
||||
type: http
|
||||
seq: 10
|
||||
}
|
||||
|
||||
delete {
|
||||
url: {{base_url}}/api/ebooks/{{ebook_id}}
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Delete Ebook
|
||||
|
||||
Deletes an ebook from the database.
|
||||
|
||||
**Method:** DELETE
|
||||
|
||||
**Endpoint:** /api/ebooks/:id
|
||||
|
||||
**Authentication:** Required (Admin only)
|
||||
|
||||
**Path Parameters:**
|
||||
- `id` (string): Ebook ID (UUID)
|
||||
|
||||
**Response:** No content (204) or success message
|
||||
|
||||
**Status Codes:**
|
||||
- 204: Ebook deleted successfully (no content)
|
||||
- 400: Bad request (invalid ID format)
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (admin access required)
|
||||
- 404: Ebook not found
|
||||
- 500: Internal server error
|
||||
|
||||
**Features:**
|
||||
- Admin-only endpoint for deleting ebooks
|
||||
- Permanent deletion (cannot be undone)
|
||||
- Cascades to delete related data (reading progress, ratings)
|
||||
- Requires valid UUID format for ebook ID
|
||||
|
||||
**Important Notes:**
|
||||
- This is a destructive operation
|
||||
- All user reading progress for this ebook will be lost
|
||||
- All user ratings for this ebook will be lost
|
||||
- Use with caution
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
meta {
|
||||
name: Update Ebook
|
||||
type: http
|
||||
seq: 9
|
||||
}
|
||||
|
||||
put {
|
||||
url: {{base_url}}/api/ebooks/{{ebook_id}}
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"title": "Updated Ebook Title",
|
||||
"author": "Updated Author Name",
|
||||
"isbn": "978-0123456789",
|
||||
"description": "Updated ebook description",
|
||||
"cover_image_path": "/path/to/updated_cover.jpg",
|
||||
"series": "Updated Series",
|
||||
"series_number": 2,
|
||||
"tags": "fiction,adventure,updated",
|
||||
"asin": "B00EXAMPLE2",
|
||||
"date_published": "2023-02-15",
|
||||
"publisher": "Updated Publisher",
|
||||
"contributors": "Updated Contributor Name"
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Update Ebook
|
||||
|
||||
Updates an existing ebook's metadata.
|
||||
|
||||
**Method:** PUT
|
||||
|
||||
**Endpoint:** /api/ebooks/:id
|
||||
|
||||
**Authentication:** Required (Admin only)
|
||||
|
||||
**Path Parameters:**
|
||||
- `id` (string): Ebook ID (UUID)
|
||||
|
||||
**Request Body:** JSON object with:
|
||||
- `title` (string, required): Updated ebook title (1-500 characters)
|
||||
- `author` (string, optional): Updated author name
|
||||
- `isbn` (string, optional): Updated ISBN number
|
||||
- `description` (string, optional): Updated ebook description
|
||||
- `cover_image_path` (string, optional): Updated path to cover image
|
||||
- `series` (string, optional): Updated series name
|
||||
- `series_number` (integer, optional): Updated number in series
|
||||
- `tags` (string, optional): Updated comma-separated tags
|
||||
- `asin` (string, optional): Updated Amazon ASIN
|
||||
- `date_published` (string, optional): Updated publication date (YYYY-MM-DD)
|
||||
- `publisher` (string, optional): Updated publisher name
|
||||
- `contributors` (string, optional): Updated contributors list
|
||||
|
||||
**Response:** Updated ebook object with all fields
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Ebook updated successfully
|
||||
- 400: Bad request (invalid data or ID)
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (admin access required)
|
||||
- 404: Ebook not found
|
||||
- 500: Internal server error
|
||||
|
||||
**Features:**
|
||||
- Admin-only endpoint for updating ebook metadata
|
||||
- Updates only provided fields, preserves others
|
||||
- Full validation of all fields
|
||||
- Cannot update file_path, file_size, or mime_type (file properties)
|
||||
}
|
||||
Reference in New Issue
Block a user