feat: Add comprehensive backend validation, toast notifications, and Tokyo Night theme

- Backend: Add server-side validation with go-playground/validator/v10
- Frontend: Add toast notifications for API errors with @zerodevx/svelte-toast
- UI: Complete Tokyo Night theme redesign with modern animations
- Docs: Update COMPLETE_DOCUMENTATION.md and README.md with all enhancements
- Validation: Email format, password strength, and input sanitization
- UX: Real-time error feedback, loading states, and responsive design
This commit is contained in:
2026-01-21 20:01:18 -05:00
parent 7448dfff30
commit 55c42f1f99
84 changed files with 7749 additions and 4 deletions
+47
View File
@@ -0,0 +1,47 @@
# Bruno API Tests for Ebook Reader
This directory contains Bruno collection for testing the Ebook Reader API with comprehensive REST documentation.
## Setup
1. Install Bruno: https://www.usebruno.com/
2. Open Bruno and import this collection folder
3. Select the "localhost" environment
4. Start the application with `docker-compose up --build`
5. Register/Login first, then use Bearer token for protected endpoints
## Available Tests
### Auth (Public Endpoints)
- **Register User**: POST /api/auth/register - Create new account
- **Login User**: POST /api/auth/login - Authenticate (email or username)
- **Get Profile**: GET /api/auth/profile - Get user info (requires token)
### Ebooks (Protected - JWT Required)
- **List Ebooks**: GET /api/ebooks - Paginated ebook list
- **Get Ebook**: GET /api/ebooks/:id - Single ebook details
- **Create Ebook**: POST /api/ebooks - Add new ebook
- **Update Ebook**: PUT /api/ebooks/:id - Modify ebook metadata
- **Delete Ebook**: DELETE /api/ebooks/:id - Remove ebook
### Reading Progress (Protected - JWT Required)
- **Get Reading Progress**: GET /api/ebooks/:id/progress - User's progress
- **Update Reading Progress**: PUT /api/ebooks/:id/progress - Update progress
## Documentation Features
Each request includes:
- **Detailed descriptions** of functionality
- **Parameter specifications** (required/optional, types)
- **Request/Response examples**
- **Error response codes** and meanings
- **Authentication requirements**
## Notes
- **Authentication Flow**: Register → Login → Use Bearer token for all other requests
- **JWT Tokens**: Valid for 24 hours, include in `Authorization: Bearer <token>` header
- **User Isolation**: Progress and data are user-specific
- **Variables**: Update `ebook_id` for testing specific ebooks
- **Security**: Passwords hashed with bcrypt, unique email/username constraints
- **JSON**: All requests/responses use JSON format
+23
View File
@@ -0,0 +1,23 @@
meta:
name: Get Profile
seq: 3
http:
method: get
url: "{{base_url}}/api/auth/profile"
auth:
type: bearer
docs: |
## Get User Profile
Retrieves the profile of the authenticated user.
**Authentication:** Required (Bearer token)
**Response:**
- `id` (string): User UUID
- `email` (string): User's email address
- `username` (string): User's username
**Error Responses:**
- 401: Invalid or missing JWT token
- 404: User not found
+29
View File
@@ -0,0 +1,29 @@
meta:
name: Login User
seq: 2
http:
method: post
url: "{{base_url}}/api/auth/login"
body:
type: json
data: |
{
"login": "test@example.com",
"password": "password123"
}
docs: |
## Login User
Authenticates a user and returns a JWT token.
**Request Body:**
- `login` (string, required): Email address or username
- `password` (string, required): User's password
**Response:**
- `token` (string): JWT authentication token (24h expiry)
- `user` (object): User profile with id, email, username
**Error Responses:**
- 401: Invalid credentials
- 400: Invalid request data
+31
View File
@@ -0,0 +1,31 @@
meta:
name: Register User
seq: 1
http:
method: post
url: "{{base_url}}/api/auth/register"
body:
type: json
data: |
{
"email": "test@example.com",
"username": "testuser",
"password": "password123"
}
docs: |
## Register User
Creates a new user account with email, username, and password.
**Request Body:**
- `email` (string, required): Valid email address
- `username` (string, required): Unique username (3-50 chars)
- `password` (string, required): Password (min 6 chars)
**Response:**
- `token` (string): JWT authentication token
- `user` (object): User profile with id, email, username
**Error Responses:**
- 409: Email or username already exists
- 400: Invalid request data
+4
View File
@@ -0,0 +1,4 @@
version: "1"
name: "Ebook Reader API"
type: collection
items: []
+43
View File
@@ -0,0 +1,43 @@
meta:
name: Create Ebook
seq: 3
http:
method: post
url: "{{base_url}}/api/ebooks"
auth:
type: bearer
body:
type: json
data: |
{
"title": "Sample Book",
"author": "Sample Author",
"isbn": "1234567890",
"description": "A sample ebook",
"file_path": "/uploads/sample.epub",
"file_size": 1024000,
"mime_type": "application/epub+zip",
"cover_image_path": "/uploads/cover.jpg"
}
docs: |
## Create Ebook
Creates a new ebook entry in the library.
**Authentication:** Required (Bearer token)
**Request Body:**
- `title` (string, required): Book title
- `author` (string, optional): Book author
- `isbn` (string, optional): ISBN number
- `description` (string, optional): Book description
- `file_path` (string, required): Path to ebook file
- `file_size` (number, optional): File size in bytes
- `mime_type` (string, optional): MIME type
- `cover_image_path` (string, optional): Path to cover image
**Response:** Created ebook object
**Error Responses:**
- 401: Invalid authentication
- 400: Invalid request data
+27
View File
@@ -0,0 +1,27 @@
meta:
name: Delete Ebook
seq: 5
http:
method: delete
url: "{{base_url}}/api/ebooks/{{ebook_id}}"
auth:
type: bearer
vars:
pre-request:
- name: ebook_id
value: "123e4567-e89b-12d3-a456-426614174000"
docs: |
## Delete Ebook
Removes an ebook from the library.
**Authentication:** Required (Bearer token)
**Path Parameters:**
- `id` (string): Ebook UUID
**Response:** 204 No Content
**Error Responses:**
- 401: Invalid authentication
- 404: Ebook not found
+27
View File
@@ -0,0 +1,27 @@
meta:
name: Get Ebook
seq: 2
http:
method: get
url: "{{base_url}}/api/ebooks/{{ebook_id}}"
auth:
type: bearer
vars:
pre-request:
- name: ebook_id
value: "123e4567-e89b-12d3-a456-426614174000"
docs: |
## Get Ebook
Retrieves details of a specific ebook.
**Authentication:** Required (Bearer token)
**Path Parameters:**
- `id` (string): Ebook UUID
**Response:** Complete ebook object with all metadata
**Error Responses:**
- 401: Invalid authentication
- 404: Ebook not found
+23
View File
@@ -0,0 +1,23 @@
meta:
name: List Ebooks
seq: 1
http:
method: get
url: "{{base_url}}/api/ebooks"
auth:
type: bearer
docs: |
## List Ebooks
Retrieves a paginated list of ebooks.
**Authentication:** Required (Bearer token)
**Query Parameters:**
- `limit` (number, optional): Number of results (default: 20, max: 100)
- `offset` (number, optional): Pagination offset (default: 0)
**Response:** Array of ebook objects with id, title, author, etc.
**Error Responses:**
- 401: Invalid authentication
+43
View File
@@ -0,0 +1,43 @@
meta:
name: Update Ebook
seq: 4
http:
method: put
url: "{{base_url}}/api/ebooks/{{ebook_id}}"
auth:
type: bearer
body:
type: json
data: |
{
"title": "Updated Book Title",
"author": "Updated Author",
"description": "Updated description"
}
vars:
pre-request:
- name: ebook_id
value: "123e4567-e89b-12d3-a456-426614174000"
docs: |
## Update Ebook
Updates an existing ebook's metadata.
**Authentication:** Required (Bearer token)
**Path Parameters:**
- `id` (string): Ebook UUID
**Request Body:** (all fields optional)
- `title` (string): Book title
- `author` (string): Book author
- `isbn` (string): ISBN number
- `description` (string): Book description
- `cover_image_path` (string): Path to cover image
**Response:** Updated ebook object
**Error Responses:**
- 401: Invalid authentication
- 404: Ebook not found
- 400: Invalid request data
+4
View File
@@ -0,0 +1,4 @@
name: localhost
variables:
- name: base_url
value: http://localhost:8765
+31
View File
@@ -0,0 +1,31 @@
meta:
name: Get Reading Progress
seq: 6
http:
method: get
url: "{{base_url}}/api/ebooks/{{ebook_id}}/progress"
auth:
type: bearer
vars:
pre-request:
- name: ebook_id
value: "123e4567-e89b-12d3-a456-426614174000"
docs: |
## Get Reading Progress
Retrieves the authenticated user's reading progress for an ebook.
**Authentication:** Required (Bearer token)
**Path Parameters:**
- `id` (string): Ebook UUID
**Response:**
- `ebook_id` (string): Ebook UUID
- `user_id` (string): User UUID
- `current_page` (number): Current page number
- `total_pages` (number, nullable): Total pages
- `last_read_at` (string): Last read timestamp
**Error Responses:**
- 401: Invalid authentication
@@ -0,0 +1,38 @@
meta:
name: Update Reading Progress
seq: 7
http:
method: put
url: "{{base_url}}/api/ebooks/{{ebook_id}}/progress"
auth:
type: bearer
body:
type: json
data: |
{
"current_page": 45,
"total_pages": 200
}
vars:
pre-request:
- name: ebook_id
value: "123e4567-e89b-12d3-a456-426614174000"
docs: |
## Update Reading Progress
Updates the authenticated user's reading progress for an ebook.
**Authentication:** Required (Bearer token)
**Path Parameters:**
- `id` (string): Ebook UUID
**Request Body:**
- `current_page` (number, required): Current page number
- `total_pages` (number, optional): Total pages in book
**Response:** Updated progress object
**Error Responses:**
- 401: Invalid authentication
- 400: Invalid request data
+3
View File
@@ -0,0 +1,3 @@
version: "1"
name: "Ebook Reader API Workspace"
type: workspace