Documentation ¶
Index ¶
- Variables
- func AddListener(listener Listener)
- func ChapterExists(chapterSlug, mangaSlug string) (bool, error)
- func Close() error
- func CountUsers() (int64, error)
- func CreateAccessToken(userName string) (string, error)
- func CreateChapter(chapter Chapter) error
- func CreateLibrary(library Library) error
- func CreateManga(manga Manga) error
- func CreateRefreshToken(userName string, version int) (string, error)
- func CreateUser(username, password string) error
- func DeleteChapter(mangaSlug, chapterSlug string) error
- func DeleteChaptersByMangaSlug(mangaSlug string) error
- func DeleteLibrary(slug string) error
- func DeleteManga(slug string) error
- func DeleteMangasByLibrarySlug(librarySlug string) error
- func GenerateNewRefreshToken(userName string) (string, error)
- func GenerateRandomKey(length int) (string, error)
- func GetAdjacentChapters(chapterSlug, mangaSlug string) (prevSlug, nextSlug string, err error)
- func GetKey() (string, error)
- func IncrementRefreshTokenVersion(username string) error
- func Initialize(cacheDirectory string) error
- func LibraryExists(slug string) (bool, error)
- func MangaCount(filterBy, filter string) (int, error)
- func MangaExists(slug string) (bool, error)
- func NotifyListeners(notification Notification)
- func RefreshAccessToken(refreshToken string) (string, string, error)
- func StoreKey(key string) error
- func UpdateChapter(chapter *Chapter) error
- func UpdateLibrary(library *Library) error
- func UpdateManga(manga *Manga) error
- func UpdateUserRole(username, newRole string) error
- func ValidateToken(tokenString string) (jwt.MapClaims, error)
- type Chapter
- type JWTKey
- type Library
- type ListMangaResponse
- type Listener
- type Manga
- type MangaAttributes
- type MangaDetail
- type Notification
- type Relationship
- type SingleMangaResponse
- type Tag
- type User
Constants ¶
This section is empty.
Variables ¶
var ListenerRegistry []Listener
ListenerRegistry is a registry of listeners interested in notifications
Functions ¶
func ChapterExists ¶
ChapterExists checks if a chapter already exists
func CreateAccessToken ¶
CreateAccessToken generates a new access token with a 15-minute expiry
func CreateChapter ¶
CreateChapter adds a new chapter if it does not already exist
func CreateLibrary ¶
CreateLibrary adds a new Library to the database
func CreateRefreshToken ¶
CreateRefreshToken generates a new refresh token with a 7-day expiry
func CreateUser ¶
CreateUser creates a new user with hashed password and default role.
func DeleteChapter ¶
DeleteChapter removes a specific chapter
func DeleteChaptersByMangaSlug ¶ added in v1.0.1
DeleteChaptersByMangaSlug removes all chapters for a specific manga
func DeleteLibrary ¶
DeleteLibrary removes a Library and its associated mangas
func DeleteManga ¶
DeleteManga removes a Manga and its associated chapters
func DeleteMangasByLibrarySlug ¶
DeleteMangasByLibrarySlug removes all mangas associated with a specific library
func GenerateNewRefreshToken ¶
GenerateNewRefreshToken creates a new refresh token and updates the user's version
func GenerateRandomKey ¶
GenerateRandomKey creates a new random key of the specified length
func GetAdjacentChapters ¶
GetAdjacentChapters finds the previous and next chapters based on the current chapter slug
func IncrementRefreshTokenVersion ¶
IncrementRefreshTokenVersion increments the refresh token version for a user.
func Initialize ¶
Initialize connects to the BoltDB database and creates necessary buckets
func LibraryExists ¶
LibraryExists checks if a Library exists by slug
func MangaCount ¶
MangaCount counts the number of mangas based on filter criteria
func MangaExists ¶
MangaExists checks if a Manga exists by slug
func NotifyListeners ¶
func NotifyListeners(notification Notification)
NotifyListeners notifies all registered listeners with a given notification
func RefreshAccessToken ¶
RefreshAccessToken generates a new access token from a valid refresh token
func UpdateChapter ¶
UpdateChapter modifies an existing chapter
func UpdateLibrary ¶
UpdateLibrary modifies an existing Library
func UpdateUserRole ¶
UpdateUserRole updates the role of a user.
func ValidateToken ¶
ValidateToken validates a token and returns its claims
Types ¶
type Chapter ¶
type Chapter struct { Slug string `json:"slug"` Name string `json:"name"` Type string `json:"type"` File string `json:"file"` ChapterCoverURL string `json:"chapter_cover_url"` MangaSlug string `json:"manga_slug"` }
func GetChapter ¶
GetChapter retrieves a specific chapter by its slug
func GetChapters ¶
GetChapters retrieves all chapters for a specific manga, sorted by name
type Library ¶
type Library struct { Slug string `json:"slug"` Name string `json:"name"` Description string `json:"description"` Cron string `json:"cron"` Folders []string `json:"folders"` CreatedAt int64 `json:"created_at"` // Unix timestamp UpdatedAt int64 `json:"updated_at"` // Unix timestamp }
func GetLibraries ¶
GetLibraries retrieves all Libraries from the database
func GetLibrary ¶
GetLibrary retrieves a single Library by slug
func SearchLibraries ¶
func SearchLibraries(keyword string, page, pageSize int, sortBy, sortOrder string) ([]Library, int64, error)
SearchLibraries finds Libraries matching the keyword and applies pagination and sorting
func (*Library) GetFolderNames ¶
GetFolderNames returns a comma-separated string of folder names
type ListMangaResponse ¶
type ListMangaResponse struct { Result string `json:"result"` Response string `json:"response"` Data []MangaDetail `json:"data"` Limit int `json:"limit,omitempty"` Offset int `json:"offset,omitempty"` Total int `json:"total,omitempty"` }
ListMangaResponse represents the JSON response for a list of mangas
func GetMangadexMangas ¶
func GetMangadexMangas(title string) (*ListMangaResponse, error)
GetMangadexMangas searches for mangas based on the title and returns a list of matches
type Listener ¶
type Listener interface {
Notify(notification Notification)
}
Listener defines the interface for objects that want to listen to notifications
type Manga ¶
type Manga struct { Slug string `json:"slug"` Name string `json:"name"` Author string `json:"author"` Description string `json:"description"` Year int `json:"year"` OriginalLanguage string `json:"original_language"` Status string `json:"status"` ContentRating string `json:"content_rating"` LibrarySlug string `json:"library_slug"` CoverArtURL string `json:"cover_art_url"` Path string `json:"path"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
type MangaAttributes ¶
type MangaAttributes struct { Title map[string]string `json:"title"` AltTitles []map[string]string `json:"altTitles"` Description map[string]string `json:"description"` IsLocked bool `json:"isLocked"` Links map[string]string `json:"links"` OriginalLanguage string `json:"originalLanguage"` LastVolume string `json:"lastVolume"` LastChapter string `json:"lastChapter"` PublicationDemographic interface{} `json:"publicationDemographic"` Status string `json:"status"` Year int `json:"year"` ContentRating string `json:"contentRating"` Tags []Tag `json:"tags"` State string `json:"state"` ChapterNumbersResetOnNewVolume bool `json:"chapterNumbersResetOnNewVolume"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` Version int `json:"version"` AvailableTranslatedLanguages []string `json:"availableTranslatedLanguages"` LatestUploadedChapter string `json:"latestUploadedChapter"` }
MangaAttributes represents the attributes of a manga in MangaDetail
type MangaDetail ¶
type MangaDetail struct { ID string `json:"id"` Type string `json:"type"` Attributes MangaAttributes `json:"attributes"` Relationships []Relationship `json:"relationships"` }
MangaDetail represents details of a manga item in the "data" array of MangaResponse
func GetBestMatchMangadexManga ¶
func GetBestMatchMangadexManga(title string) (*MangaDetail, error)
GetBestMatchMangadexManga returns the best match manga based on the title
func GetMangadexManga ¶
func GetMangadexManga(id string) (*MangaDetail, error)
GetMangadexManga fetches manga details by ID from the MangaDex API
type Notification ¶
type Notification struct { Type string // Type of notification (e.g., "library_created", "library_updated", etc.) Payload interface{} // Data associated with the notification }
Notification represents a notification object
type Relationship ¶
type Relationship struct { ID string `json:"id"` Type string `json:"type"` Attributes interface{} `json:"attributes"` // General type for flexibility }
Relationship represents the relationship details in MangaDetail
type SingleMangaResponse ¶
type SingleMangaResponse struct { Result string `json:"result"` Response string `json:"response"` Data MangaDetail `json:"data"` }
SingleMangaResponse represents the JSON response for a single manga
type Tag ¶ added in v1.0.2
type Tag struct { ID string `json:"id"` Type string `json:"type"` Attributes struct { Name map[string]string `json:"name"` Description map[string]string `json:"description"` Group string `json:"group"` Version int `json:"version"` } `json:"attributes"` Relationships []interface{} `json:"relationships"` }
Tag represents a tag in MangaAttributes