First Commit. AI Generated App.
This commit is contained in:
+4
-1
@@ -188,4 +188,7 @@ coverage/
|
||||
|
||||
# Deployment
|
||||
.vercel
|
||||
.netlify
|
||||
.netlify
|
||||
|
||||
# Bruno environment folder
|
||||
#environment/
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
meta {
|
||||
name: Get Profile
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/auth/profile
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get User Profile
|
||||
|
||||
Retrieves the authenticated user's profile.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/auth/profile
|
||||
|
||||
**Authentication:** Required
|
||||
|
||||
**Response:**
|
||||
- `id` (string): User ID
|
||||
- `email` (string): Email
|
||||
- `username` (string): Username
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
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
|
||||
@@ -0,0 +1,45 @@
|
||||
meta {
|
||||
name: Login User
|
||||
type: http
|
||||
seq: 2
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{base_url}}/api/auth/login
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"login": "test@example.com",
|
||||
"password": "password123"
|
||||
}
|
||||
}
|
||||
|
||||
docs {
|
||||
## Login User
|
||||
|
||||
Authenticates a user with email/username and password.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/auth/login
|
||||
|
||||
**Request Body:**
|
||||
- `login` (string): Email or username
|
||||
- `password` (string): Password
|
||||
|
||||
**Response:**
|
||||
- `token` (string): JWT token
|
||||
- `user` (object): User details
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Invalid credentials
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
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
|
||||
@@ -0,0 +1,47 @@
|
||||
meta {
|
||||
name: Register User
|
||||
type: http
|
||||
seq: 3
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{base_url}}/api/auth/register
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"email": "test@example.com",
|
||||
"username": "testuser",
|
||||
"password": "password123"
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Register User
|
||||
|
||||
Creates a new user account.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/auth/register
|
||||
|
||||
**Request Body:**
|
||||
- `email` (string): Email address
|
||||
- `username` (string): Username
|
||||
- `password` (string): Password
|
||||
|
||||
**Response:**
|
||||
- `token` (string): JWT token
|
||||
- `user` (object): User details
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Created
|
||||
- 409: User exists
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
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
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": "1",
|
||||
"name": "Bookmann API",
|
||||
"type": "collection"
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
version: "1"
|
||||
name: "Bookmann API"
|
||||
type: collection
|
||||
items: []
|
||||
@@ -1,25 +1,34 @@
|
||||
meta:
|
||||
meta {
|
||||
name: Create Ebook
|
||||
type: http
|
||||
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: |
|
||||
}
|
||||
|
||||
post {
|
||||
url: http://localhost:8765/api/ebooks
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Create Ebook
|
||||
|
||||
Creates a new ebook entry in the library.
|
||||
@@ -40,4 +49,5 @@ docs: |
|
||||
|
||||
**Error Responses:**
|
||||
- 401: Invalid authentication
|
||||
- 400: Invalid request data
|
||||
- 400: Invalid request data
|
||||
}
|
||||
@@ -1,16 +1,24 @@
|
||||
meta:
|
||||
meta {
|
||||
name: Delete Ebook
|
||||
type: http
|
||||
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 {
|
||||
url: http://localhost:8765/api/ebooks/123e4567-e89b-12d3-a456-426614174000
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
docs {
|
||||
## Delete Ebook
|
||||
|
||||
Removes an ebook from the library.
|
||||
@@ -24,4 +32,5 @@ docs: |
|
||||
|
||||
**Error Responses:**
|
||||
- 401: Invalid authentication
|
||||
- 404: Ebook not found
|
||||
- 404: Ebook not found
|
||||
}
|
||||
@@ -1,16 +1,24 @@
|
||||
meta:
|
||||
meta {
|
||||
name: Get Ebook
|
||||
type: http
|
||||
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 {
|
||||
url: http://localhost:8765/api/ebooks/123e4567-e89b-12d3-a456-426614174000
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
docs {
|
||||
## Get Ebook
|
||||
|
||||
Retrieves details of a specific ebook.
|
||||
@@ -24,4 +32,5 @@ docs: |
|
||||
|
||||
**Error Responses:**
|
||||
- 401: Invalid authentication
|
||||
- 404: Ebook not found
|
||||
- 404: Ebook not found
|
||||
}
|
||||
@@ -1,12 +1,22 @@
|
||||
meta:
|
||||
meta {
|
||||
name: List Ebooks
|
||||
type: http
|
||||
seq: 1
|
||||
http:
|
||||
method: get
|
||||
url: "{{base_url}}/api/ebooks"
|
||||
auth:
|
||||
type: bearer
|
||||
docs: |
|
||||
}
|
||||
|
||||
get {
|
||||
url: http://localhost:8765/api/ebooks
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
docs {
|
||||
## List Ebooks
|
||||
|
||||
Retrieves a paginated list of ebooks.
|
||||
@@ -20,4 +30,5 @@ docs: |
|
||||
**Response:** Array of ebook objects with id, title, author, etc.
|
||||
|
||||
**Error Responses:**
|
||||
- 401: Invalid authentication
|
||||
- 401: Invalid authentication
|
||||
}
|
||||
@@ -1,24 +1,29 @@
|
||||
meta:
|
||||
meta {
|
||||
name: Update Ebook
|
||||
type: http
|
||||
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: |
|
||||
}
|
||||
|
||||
put {
|
||||
url: http://localhost:8765/api/ebooks/123e4567-e89b-12d3-a456-426614174000
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"title": "Updated Book Title",
|
||||
"author": "Updated Author",
|
||||
"description": "Updated description"
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Update Ebook
|
||||
|
||||
Updates an existing ebook's metadata.
|
||||
@@ -40,4 +45,5 @@ docs: |
|
||||
**Error Responses:**
|
||||
- 401: Invalid authentication
|
||||
- 404: Ebook not found
|
||||
- 400: Invalid request data
|
||||
- 400: Invalid request data
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
vars {
|
||||
base_url: http://localhost:8765
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
name: localhost
|
||||
variables:
|
||||
- name: base_url
|
||||
value: http://localhost:8765
|
||||
@@ -1,16 +1,20 @@
|
||||
meta:
|
||||
meta {
|
||||
name: Get Reading Progress
|
||||
type: http
|
||||
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 {
|
||||
url: http://localhost:8765/api/ebooks/123e4567-e89b-12d3-a456-426614174000/progress
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get Reading Progress
|
||||
|
||||
Retrieves the authenticated user's reading progress for an ebook.
|
||||
@@ -28,4 +32,5 @@ docs: |
|
||||
- `last_read_at` (string): Last read timestamp
|
||||
|
||||
**Error Responses:**
|
||||
- 401: Invalid authentication
|
||||
- 401: Invalid authentication
|
||||
}
|
||||
+25
-19
@@ -1,23 +1,28 @@
|
||||
meta:
|
||||
meta {
|
||||
name: Update Reading Progress
|
||||
type: http
|
||||
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: |
|
||||
}
|
||||
|
||||
put {
|
||||
url: http://localhost:8765/api/ebooks/123e4567-e89b-12d3-a456-426614174000/progress
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"current_page": 45,
|
||||
"total_pages": 200
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Update Reading Progress
|
||||
|
||||
Updates the authenticated user's reading progress for an ebook.
|
||||
@@ -35,4 +40,5 @@ docs: |
|
||||
|
||||
**Error Responses:**
|
||||
- 401: Invalid authentication
|
||||
- 400: Invalid request data
|
||||
- 400: Invalid request data
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
version: "1"
|
||||
name: "Bookmann API Workspace"
|
||||
type: workspace
|
||||
@@ -36,15 +36,15 @@
|
||||
<p class="text-tokyo-fg-dark">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
{:else if ebooks.length === 0}
|
||||
<div class="card max-w-lg mx-auto text-center">
|
||||
<div class="card-body">
|
||||
<div class="text-6xl mb-4">📖</div>
|
||||
<h3 class="text-2xl font-semibold text-tokyo-fg mb-2">Welcome to your library!</h3>
|
||||
<p class="text-tokyo-fg-dark mb-6">You haven't added any ebooks yet. Start building your collection by uploading your favorite books.</p>
|
||||
<button class="btn-primary">Add Your First Ebook</button>
|
||||
</div>
|
||||
</div>
|
||||
{:else if ebooks.length === 0}
|
||||
<div class="card max-w-lg mx-auto text-center">
|
||||
<div class="card-body">
|
||||
<div class="text-6xl mb-4">📖</div>
|
||||
<h3 class="text-2xl font-semibold text-tokyo-fg mb-2">Welcome to your library!</h3>
|
||||
<p class="text-tokyo-fg-dark mb-6">You haven't added any ebooks yet. Start building your collection by uploading your favorite books.</p>
|
||||
<a href="/upload" class="btn-primary inline-block">Add Your First Ebook</a>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8">
|
||||
{#each ebooks as ebook (ebook.id)}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { Actions } from './$types';
|
||||
import { createEbook } from '$lib/api';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export const actions: Actions = {
|
||||
default: async ({ request, fetch }) => {
|
||||
const data = await request.formData();
|
||||
const title = data.get('title') as string;
|
||||
const author = data.get('author') as string;
|
||||
const description = data.get('description') as string;
|
||||
const file = data.get('file') as File;
|
||||
|
||||
if (!title || !file) {
|
||||
return { success: false, error: 'Title and file are required' };
|
||||
}
|
||||
|
||||
try {
|
||||
// For now, simulate upload - in reality, the backend would handle file upload
|
||||
// and return the ebook data
|
||||
const ebookData = {
|
||||
title,
|
||||
author: author || null,
|
||||
description: description || null,
|
||||
file_path: `/uploads/${file.name}`, // Placeholder
|
||||
};
|
||||
|
||||
await createEbook(ebookData);
|
||||
throw redirect(303, '/');
|
||||
} catch (err) {
|
||||
if (err instanceof Response) throw err; // Redirect
|
||||
return { success: false, error: err instanceof Error ? err.message : 'Upload failed' };
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,105 @@
|
||||
<script lang="ts">
|
||||
import { enhance } from '$app/forms';
|
||||
import { page } from '$app/stores';
|
||||
import { goto } from '$app/navigation';
|
||||
import { showError } from '$lib/toast';
|
||||
|
||||
let loading = false;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Upload Ebook - Bookmann</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="min-h-screen flex items-center justify-center bg-gradient-to-br from-tokyo-bg to-tokyo-bg-dark py-12 px-4 sm:px-6 lg:px-8">
|
||||
<div class="max-w-md w-full animate-slide-in">
|
||||
<div class="card">
|
||||
<div class="card-header text-center">
|
||||
<div class="text-4xl mb-4">📤</div>
|
||||
<h2 class="text-2xl font-bold text-tokyo-fg">
|
||||
Upload Ebook
|
||||
</h2>
|
||||
<p class="text-tokyo-fg-dark mt-2">Add a new book to your library</p>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" enctype="multipart/form-data" use:enhance={() => {
|
||||
loading = true;
|
||||
return async ({ update }) => {
|
||||
try {
|
||||
await update();
|
||||
goto('/');
|
||||
} catch (err) {
|
||||
showError('Upload failed');
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
};
|
||||
}}>
|
||||
<div class="space-y-6">
|
||||
<div>
|
||||
<label for="title" class="block text-sm font-medium text-tokyo-fg mb-2">
|
||||
Title *
|
||||
</label>
|
||||
<input
|
||||
id="title"
|
||||
name="title"
|
||||
type="text"
|
||||
required
|
||||
class="input-field w-full"
|
||||
placeholder="Enter book title"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="author" class="block text-sm font-medium text-tokyo-fg mb-2">
|
||||
Author
|
||||
</label>
|
||||
<input
|
||||
id="author"
|
||||
name="author"
|
||||
type="text"
|
||||
class="input-field w-full"
|
||||
placeholder="Enter author name"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="description" class="block text-sm font-medium text-tokyo-fg mb-2">
|
||||
Description
|
||||
</label>
|
||||
<textarea
|
||||
id="description"
|
||||
name="description"
|
||||
rows="3"
|
||||
class="input-field w-full resize-none"
|
||||
placeholder="Brief description of the book"
|
||||
></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label for="file" class="block text-sm font-medium text-tokyo-fg mb-2">
|
||||
Ebook File *
|
||||
</label>
|
||||
<input
|
||||
id="file"
|
||||
name="file"
|
||||
type="file"
|
||||
accept=".pdf,.epub,.mobi,.txt"
|
||||
required
|
||||
class="input-field w-full file:mr-4 file:py-2 file:px-4 file:rounded-l file:border-0 file:text-sm file:font-semibold file:bg-tokyo-bg-highlight file:text-tokyo-fg hover:file:bg-tokyo-bg-selection"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
class="btn-primary w-full flex justify-center items-center mt-6 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{#if loading}
|
||||
<div class="animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent mr-2"></div>
|
||||
{/if}
|
||||
{loading ? 'Uploading...' : 'Upload Ebook'}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user