chore(bruno): update library API collection and add dev DB setup

Update all library API request files to the current Bruno format
with proper settings blocks, updated sequence numbers, and cleaner
YAML formatting.

Add NewDevDBSetup collection with requests for creating comic, ebook,
and manga libraries, user registration, and folder configuration to
speed up development environment setup.
This commit is contained in:
2026-04-19 14:27:35 -04:00
parent c337b46bef
commit e2d2dbecab
18 changed files with 484 additions and 75 deletions
@@ -0,0 +1,83 @@
info:
name: CreateComicLibrary
type: http
seq: 3
http:
method: POST
url: "{{base_url}}/api/libraries"
body:
type: json
data: |-
{
"name": "My Ebook Library",
"description": "A collection of technical books and novels",
"type": "ebooks"
}
auth: inherit
runtime:
scripts:
- type: after-response
code: |-
function onResponse(res) {
try {
const responseBody = res.getBody();
const id = responseBody.id;
if (id) {
bru.setEnvVar("library_id", id, { persist: true });
console.log("Library ID saved:", id);
}
if (!id) {
console.log("No id found in response.");
}
} catch (error) {
console.error("Error in post-response script:", error.message);
}
}
onResponse(res);
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
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
@@ -0,0 +1,83 @@
info:
name: CreateEbookLibrary
type: http
seq: 1
http:
method: POST
url: "{{base_url}}/api/libraries"
body:
type: json
data: |-
{
"name": "My Ebook Library",
"description": "A collection of technical books and novels",
"type": "ebooks"
}
auth: inherit
runtime:
scripts:
- type: after-response
code: |-
function onResponse(res) {
try {
const responseBody = res.getBody();
const id = responseBody.id;
if (id) {
bru.setEnvVar("library_id", id, { persist: true });
console.log("Library ID saved:", id);
}
if (!id) {
console.log("No id found in response.");
}
} catch (error) {
console.error("Error in post-response script:", error.message);
}
}
onResponse(res);
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
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
@@ -0,0 +1,83 @@
info:
name: CreateMangaLibrary
type: http
seq: 4
http:
method: POST
url: "{{base_url}}/api/libraries"
body:
type: json
data: |-
{
"name": "My Ebook Library",
"description": "A collection of technical books and novels",
"type": "ebooks"
}
auth: inherit
runtime:
scripts:
- type: after-response
code: |-
function onResponse(res) {
try {
const responseBody = res.getBody();
const id = responseBody.id;
if (id) {
bru.setEnvVar("library_id", id, { persist: true });
console.log("Library ID saved:", id);
}
if (!id) {
console.log("No id found in response.");
}
} catch (error) {
console.error("Error in post-response script:", error.message);
}
}
onResponse(res);
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
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
+98
View File
@@ -0,0 +1,98 @@
info:
name: RegisterUser
type: http
seq: 2
http:
method: POST
url: "{{base_url}}/api/auth/register"
body:
type: json
data: |-
{
"username": "testuser",
"email": "testuser@tests.bookhoard.internal",
"password": "Test@Pass123!",
"first_name": "Test",
"last_name": "User"
}
auth: inherit
runtime:
scripts:
- type: after-response
code: |-
function onResponse(res) {
try {
const responseBody = res.getBody();
const token = responseBody.access_token;
const refreshToken = responseBody.refresh_token;
if (token) {
bru.setEnvVar("token", token, { persist: true });
console.log("Access token saved:", token);
}
if (refreshToken) {
bru.setEnvVar("refresh_token", refreshToken, { persist: true });
console.log("Refresh token saved:", refreshToken);
}
if (!token && !refreshToken) {
console.log("No tokens found in response.");
}
} catch (error) {
console.error("Error in post-response script:", error.message);
}
}
onResponse(res);
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
docs: |-
## Register User
Creates a new user account with role-based restrictions.
**Method:** POST
**Endpoint:** /api/auth/register
**Request Body:**
- `email` (string): Email address
- `username` (string): Username
- `password` (string): Password
- `first_name` (string, optional): First name
- `last_name` (string, optional): Last name
- `role` (string): User role ("user" or "admin")
**Response:**
- `token` (string): JWT token
- `user` (object): User details
- `id` (string): User ID
- `email` (string): Email
- `username` (string): Username
- `theme` (string): User theme preference
- `first_name` (string, optional): First name
- `last_name` (string, optional): Last name
- `role` (string): User role ("user" or "admin")
**Status Codes:**
- 201: Created
- 400: Invalid input data
- 403: Forbidden - role-based restrictions apply
- 409: User exists
**Role Restrictions:**
- **First User**: Automatically gets admin role regardless of request
- **Existing Admins Present**: Only authenticated admins can create new admin accounts
- **No Admins Yet**: Anyone can create first admin (auto-assigned)
- **Regular User Creation**: Anyone can create regular user accounts
- **Unauthenticated Users**: Can only create first admin, not subsequent admins
**Examples:**
- First admin creation: `{"email": "admin@example.com", "username": "admin", "password": "password123", "role": "admin"
+7
View File
@@ -0,0 +1,7 @@
info:
name: NewDevDBSetup
type: folder
seq: 22
request:
auth: inherit
+1 -1
View File
@@ -1,7 +1,7 @@
info: info:
name: Create Library name: Create Library
type: http type: http
seq: 1 seq: 2
http: http:
method: POST method: POST
+19 -10
View File
@@ -1,23 +1,32 @@
info: info:
name: Delete Library Folder name: Delete Library Folder
type: http type: http
seq: 4 seq: 13
http: http:
method: DELETE method: DELETE
url: '{{base_url}}/api/libraries/{{library_id}}/folders' url: "{{base_url}}/api/libraries/{{library_id}}/folders"
auth: inherit headers:
- name: ""
value: application/json
body: body:
type: json type: json
json: data: ""
folder_path: /path/to/folder auth: inherit
headers:
- key: Content-Type
value: application/json
runtime: runtime:
scripts: scripts:
- type: tests - type: tests
code: "test_delete_library_folder_success(status, headers, body) {\n if (status\ code: |-
\ !== 204) {\n throw new Error(\"Expected status 204, got \" + status);" test_delete_library_folder_success(status, headers, body) {
if (status !== 204) {
throw new Error("Expected status 204, got " + status);
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
docs: |- docs: |-
## Delete Library Folder ## Delete Library Folder
+1 -1
View File
@@ -1,7 +1,7 @@
info: info:
name: Delete Library name: Delete Library
type: http type: http
seq: 3 seq: 12
http: http:
method: DELETE method: DELETE
+1 -1
View File
@@ -1,7 +1,7 @@
info: info:
name: Get Libraries (Admin) name: Get Libraries (Admin)
type: http type: http
seq: 1 seq: 3
http: http:
method: GET method: GET
+11 -6
View File
@@ -1,16 +1,21 @@
info: info:
name: Get Library Folders name: Get Library Folders
type: http type: http
seq: 1 seq: 5
http: http:
method: GET method: GET
url: '{{base_url}}/api/libraries/{{library_id}}/folders' url: "{{base_url}}/api/libraries/{{library_id}}/folders"
auth: inherit
body:
type: none
headers: headers:
- key: Content-Type - name: ""
value: application/json value: application/json
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
docs: |- docs: |-
## Get Library Folders ## Get Library Folders
+16 -8
View File
@@ -1,21 +1,29 @@
info: info:
name: Get Library Stats name: Get Library Stats
type: http type: http
seq: 5 seq: 14
http: http:
method: GET method: GET
url: '{{base_url}}/api/libraries/{{library_id}}/stats' url: "{{base_url}}/api/libraries/{{library_id}}/stats"
auth: inherit
body:
type: none
headers: headers:
- key: Content-Type - name: ""
value: application/json value: application/json
auth: inherit
runtime: runtime:
scripts: scripts:
- type: tests - type: tests
code: "test_get_library_stats_success(status, headers, body) {\n if (status\ code: |-
\ !== 200) {\n throw new Error(\"Expected status 200, got \" + status);" test_get_library_stats_success(status, headers, body) {
if (status !== 200) {
throw new Error("Expected status 200, got " + status);
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
docs: |- docs: |-
## Get Library Stats ## Get Library Stats
+11 -6
View File
@@ -1,16 +1,21 @@
info: info:
name: Get Library Types name: Get Library Types
type: http type: http
seq: 1 seq: 6
http: http:
method: GET method: GET
url: '{{base_url}}/api/libraries/types' url: "{{base_url}}/api/libraries/types"
auth: inherit
body:
type: none
headers: headers:
- key: Content-Type - name: ""
value: application/json value: application/json
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
docs: |- docs: |-
## Get Library Types ## Get Library Types
+16 -8
View File
@@ -1,21 +1,29 @@
info: info:
name: Get Library name: Get Library
type: http type: http
seq: 1 seq: 4
http: http:
method: GET method: GET
url: '{{base_url}}/api/libraries/{{library_id}}' url: "{{base_url}}/api/libraries/{{library_id}}"
auth: inherit
body:
type: none
headers: headers:
- key: Content-Type - name: ""
value: application/json value: application/json
auth: inherit
runtime: runtime:
scripts: scripts:
- type: tests - type: tests
code: "test_get_library_success(status, headers, body) {\n if (status !== 200)\ code: |-
\ {\n throw new Error(\"Expected status 200, got \" + status);" test_get_library_success(status, headers, body) {
if (status !== 200) {
throw new Error("Expected status 200, got " + status);
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
docs: |- docs: |-
## Get Library ## Get Library
+1 -1
View File
@@ -1,7 +1,7 @@
info: info:
name: Get Scan Settings name: Get Scan Settings
type: http type: http
seq: 2 seq: 10
http: http:
method: GET method: GET
+11 -6
View File
@@ -1,16 +1,21 @@
info: info:
name: Get User Visible Libraries name: Get User Visible Libraries
type: http type: http
seq: 1 seq: 7
http: http:
method: GET method: GET
url: '{{base_url}}/api/libraries/visible' url: "{{base_url}}/api/libraries/visible"
auth: inherit
body:
type: none
headers: headers:
- key: Content-Type - name: ""
value: application/json value: application/json
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
docs: |- docs: |-
## Get User Visible Libraries ## Get User Visible Libraries
+13 -6
View File
@@ -1,11 +1,14 @@
info: info:
name: Set Library Visibility name: Set Library Visibility
type: http type: http
seq: 1 seq: 8
http: http:
method: POST method: POST
url: '{{base_url}}/api/libraries/visibility' url: "{{base_url}}/api/libraries/visibility"
auth: inherit headers:
- name: ""
value: application/json
body: body:
type: json type: json
data: |- data: |-
@@ -13,9 +16,13 @@ http:
"library_id": "{{library_id}}", "library_id": "{{library_id}}",
"is_visible": true "is_visible": true
} }
headers: auth: inherit
- key: Content-Type
value: application/json settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
docs: |- docs: |-
## Set Library Visibility ## Set Library Visibility
+19 -11
View File
@@ -1,24 +1,32 @@
info: info:
name: Update Library name: Update Library
type: http type: http
seq: 2 seq: 11
http: http:
method: PUT method: PUT
url: '{{base_url}}/api/libraries/{{library_id}}' url: "{{base_url}}/api/libraries/{{library_id}}"
auth: inherit headers:
- name: ""
value: application/json
body: body:
type: json type: json
json: data: ""
name: Updated Library Name auth: inherit
description: Updated library description
headers:
- key: Content-Type
value: application/json
runtime: runtime:
scripts: scripts:
- type: tests - type: tests
code: "test_update_library_success(status, headers, body) {\n if (status !==\ code: |-
\ 200) {\n throw new Error(\"Expected status 200, got \" + status);" test_update_library_success(status, headers, body) {
if (status !== 200) {
throw new Error("Expected status 200, got " + status);
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
docs: |- docs: |-
## Update Library ## Update Library
+1 -1
View File
@@ -1,7 +1,7 @@
info: info:
name: Update Scan Settings name: Update Scan Settings
type: http type: http
seq: 1 seq: 9
http: http:
method: PUT method: PUT