mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
Update Koa
This commit is contained in:
parent
df7e2270a4
commit
1b25a1fa47
@ -50,7 +50,7 @@ shards:
|
|||||||
|
|
||||||
koa:
|
koa:
|
||||||
git: https://github.com/hkalexling/koa.git
|
git: https://github.com/hkalexling/koa.git
|
||||||
version: 0.5.0
|
version: 0.7.0
|
||||||
|
|
||||||
mangadex:
|
mangadex:
|
||||||
git: https://github.com/hkalexling/mangadex.git
|
git: https://github.com/hkalexling/mangadex.git
|
||||||
|
@ -10,7 +10,7 @@ struct APIRouter
|
|||||||
macro s(fields)
|
macro s(fields)
|
||||||
{
|
{
|
||||||
{% for field in fields %}
|
{% for field in fields %}
|
||||||
{{field}} => "string",
|
{{field}} => String,
|
||||||
{% end %}
|
{% end %}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -33,160 +33,47 @@ struct APIRouter
|
|||||||
MD
|
MD
|
||||||
|
|
||||||
Koa.cookie_auth "cookie", "mango-sessid-#{Config.current.port}"
|
Koa.cookie_auth "cookie", "mango-sessid-#{Config.current.port}"
|
||||||
Koa.global_tag "admin", desc: <<-MD
|
Koa.define_tag "admin", desc: <<-MD
|
||||||
These are the admin endpoints only accessible for users with admin access. A non-admin user will get HTTP 403 when calling the endpoints.
|
These are the admin endpoints only accessible for users with admin access. A non-admin user will get HTTP 403 when calling the endpoints.
|
||||||
MD
|
MD
|
||||||
|
|
||||||
Koa.binary "binary", desc: "A binary file"
|
Koa.schema "entry", {
|
||||||
Koa.array "entryAry", "$entry", desc: "An array of entries"
|
"pages" => Int32,
|
||||||
Koa.array "titleAry", "$title", desc: "An array of titles"
|
"mtime" => Int64,
|
||||||
Koa.array "strAry", "string", desc: "An array of strings"
|
}.merge(s %w(zip_path title size id title_id display_name cover_url)),
|
||||||
|
desc: "An entry in a book"
|
||||||
|
|
||||||
entry_schema = {
|
Koa.schema "title", {
|
||||||
"pages" => "integer",
|
"mtime" => Int64,
|
||||||
"mtime" => "integer",
|
"entries" => ["entry"],
|
||||||
}.merge s %w(zip_path title size id title_id display_name cover_url)
|
"titles" => ["title"],
|
||||||
Koa.object "entry", entry_schema, desc: "An entry in a book"
|
"parents" => [String],
|
||||||
|
}.merge(s %w(dir title id display_name cover_url)),
|
||||||
title_schema = {
|
|
||||||
"mtime" => "integer",
|
|
||||||
"entries" => "$entryAry",
|
|
||||||
"titles" => "$titleAry",
|
|
||||||
"parents" => "$strAry",
|
|
||||||
}.merge s %w(dir title id display_name cover_url)
|
|
||||||
Koa.object "title", title_schema,
|
|
||||||
desc: "A manga title (a collection of entries and sub-titles)"
|
desc: "A manga title (a collection of entries and sub-titles)"
|
||||||
|
|
||||||
Koa.object "library", {
|
Koa.schema "result", {
|
||||||
"dir" => "string",
|
"success" => Bool,
|
||||||
"titles" => "$titleAry",
|
"error" => String?,
|
||||||
}, desc: "A library containing a list of top-level titles"
|
|
||||||
|
|
||||||
Koa.object "scanResult", {
|
|
||||||
"milliseconds" => "integer",
|
|
||||||
"titles" => "integer",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Koa.object "progressResult", {
|
Koa.schema("mdChapter", {
|
||||||
"progress" => "number",
|
"group" => {} of String => String,
|
||||||
}
|
}.merge(s %w(id title volume chapter language full_title time
|
||||||
|
manga_title manga_id)),
|
||||||
|
desc: "A MangaDex chapter")
|
||||||
|
|
||||||
Koa.object "result", {
|
Koa.schema "mdManga", {
|
||||||
"success" => "boolean",
|
"chapters" => ["mdChapter"],
|
||||||
"error" => "string?",
|
}.merge(s %w(id title description author artist cover_url)),
|
||||||
}
|
desc: "A MangaDex manga"
|
||||||
|
|
||||||
mc_schema = {
|
|
||||||
"groups" => "object",
|
|
||||||
}.merge s %w(id title volume chapter language full_title time manga_title manga_id)
|
|
||||||
Koa.object "mangadexChapter", mc_schema, desc: "A MangaDex chapter"
|
|
||||||
|
|
||||||
Koa.array "chapterAry", "$mangadexChapter"
|
|
||||||
|
|
||||||
mm_schema = {
|
|
||||||
"chapers" => "$chapterAry",
|
|
||||||
}.merge s %w(id title description author artist cover_url)
|
|
||||||
Koa.object "mangadexManga", mm_schema, desc: "A MangaDex manga"
|
|
||||||
|
|
||||||
Koa.object "chaptersObj", {
|
|
||||||
"chapters" => "$chapterAry",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.object "successFailCount", {
|
|
||||||
"success" => "integer",
|
|
||||||
"fail" => "integer",
|
|
||||||
}
|
|
||||||
|
|
||||||
job_schema = {
|
|
||||||
"pages" => "integer",
|
|
||||||
"success_count" => "integer",
|
|
||||||
"fail_count" => "integer",
|
|
||||||
"time" => "integer",
|
|
||||||
}.merge s %w(id manga_id title manga_title status_message status)
|
|
||||||
Koa.object "job", job_schema, desc: "A download job in the queue"
|
|
||||||
|
|
||||||
Koa.array "jobAry", "$job"
|
|
||||||
|
|
||||||
Koa.object "jobs", {
|
|
||||||
"success" => "boolean",
|
|
||||||
"paused" => "boolean",
|
|
||||||
"jobs" => "$jobAry",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.object "binaryUpload", {
|
|
||||||
"file" => "$binary",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.object "pluginListBody", {
|
|
||||||
"plugin" => "string",
|
|
||||||
"query" => "string",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.object "pluginChapter", {
|
|
||||||
"id" => "string",
|
|
||||||
"title" => "string",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.array "pluginChapterAry", "$pluginChapter"
|
|
||||||
|
|
||||||
Koa.object "pluginList", {
|
|
||||||
"success" => "boolean",
|
|
||||||
"chapters" => "$pluginChapterAry?",
|
|
||||||
"title" => "string?",
|
|
||||||
"error" => "string?",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.object "pluginDownload", {
|
|
||||||
"plugin" => "string",
|
|
||||||
"title" => "string",
|
|
||||||
"chapters" => "$pluginChapterAry",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.object "dimension", {
|
|
||||||
"width" => "integer",
|
|
||||||
"height" => "integer",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.array "dimensionAry", "$dimension"
|
|
||||||
|
|
||||||
Koa.object "dimensionResult", {
|
|
||||||
"success" => "boolean",
|
|
||||||
"dimensions" => "$dimensionAry?",
|
|
||||||
"margin" => "number",
|
|
||||||
"error" => "string?",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.object "ids", {
|
|
||||||
"ids" => "$strAry",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.object "tagsResult", {
|
|
||||||
"success" => "boolean",
|
|
||||||
"tags" => "$strAry?",
|
|
||||||
"error" => "string?",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.object "missing", {
|
|
||||||
"path" => "string",
|
|
||||||
"id" => "string",
|
|
||||||
"signature" => "string",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.array "missingAry", "$missing"
|
|
||||||
|
|
||||||
Koa.object "missingResult", {
|
|
||||||
"success" => "boolean",
|
|
||||||
"error" => "string?",
|
|
||||||
"entries" => "$missingAry?",
|
|
||||||
"titles" => "$missingAry?",
|
|
||||||
}
|
|
||||||
|
|
||||||
Koa.describe "Returns a page in a manga entry"
|
Koa.describe "Returns a page in a manga entry"
|
||||||
Koa.path "tid", desc: "Title ID"
|
Koa.path "tid", desc: "Title ID"
|
||||||
Koa.path "eid", desc: "Entry ID"
|
Koa.path "eid", desc: "Entry ID"
|
||||||
Koa.path "page", type: "integer", desc: "The page number to return (starts from 1)"
|
Koa.path "page", schema: Int32, desc: "The page number to return (starts from 1)"
|
||||||
Koa.response 200, ref: "$binary", media_type: "image/*"
|
Koa.response 200, schema: Bytes, media_type: "image/*"
|
||||||
Koa.response 500, "Page not found or not readable"
|
Koa.response 500, "Page not found or not readable"
|
||||||
|
Koa.tag "reader"
|
||||||
get "/api/page/:tid/:eid/:page" do |env|
|
get "/api/page/:tid/:eid/:page" do |env|
|
||||||
begin
|
begin
|
||||||
tid = env.params.url["tid"]
|
tid = env.params.url["tid"]
|
||||||
@ -212,8 +99,9 @@ struct APIRouter
|
|||||||
Koa.describe "Returns the cover image of a manga entry"
|
Koa.describe "Returns the cover image of a manga entry"
|
||||||
Koa.path "tid", desc: "Title ID"
|
Koa.path "tid", desc: "Title ID"
|
||||||
Koa.path "eid", desc: "Entry ID"
|
Koa.path "eid", desc: "Entry ID"
|
||||||
Koa.response 200, ref: "$binary", media_type: "image/*"
|
Koa.response 200, schema: Bytes, media_type: "image/*"
|
||||||
Koa.response 500, "Page not found or not readable"
|
Koa.response 500, "Page not found or not readable"
|
||||||
|
Koa.tag "library"
|
||||||
get "/api/cover/:tid/:eid" do |env|
|
get "/api/cover/:tid/:eid" do |env|
|
||||||
begin
|
begin
|
||||||
tid = env.params.url["tid"]
|
tid = env.params.url["tid"]
|
||||||
@ -238,8 +126,9 @@ struct APIRouter
|
|||||||
|
|
||||||
Koa.describe "Returns the book with title `tid`"
|
Koa.describe "Returns the book with title `tid`"
|
||||||
Koa.path "tid", desc: "Title ID"
|
Koa.path "tid", desc: "Title ID"
|
||||||
Koa.response 200, ref: "$title"
|
Koa.response 200, schema: "title"
|
||||||
Koa.response 404, "Title not found"
|
Koa.response 404, "Title not found"
|
||||||
|
Koa.tag "library"
|
||||||
get "/api/book/:tid" do |env|
|
get "/api/book/:tid" do |env|
|
||||||
begin
|
begin
|
||||||
tid = env.params.url["tid"]
|
tid = env.params.url["tid"]
|
||||||
@ -255,14 +144,21 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Returns the entire library with all titles and entries"
|
Koa.describe "Returns the entire library with all titles and entries"
|
||||||
Koa.response 200, ref: "$library"
|
Koa.response 200, schema: {
|
||||||
|
"dir" => String,
|
||||||
|
"titles" => ["title"],
|
||||||
|
}
|
||||||
|
Koa.tag "library"
|
||||||
get "/api/library" do |env|
|
get "/api/library" do |env|
|
||||||
send_json env, Library.default.to_json
|
send_json env, Library.default.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Triggers a library scan"
|
Koa.describe "Triggers a library scan"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "library"]
|
||||||
Koa.response 200, ref: "$scanResult"
|
Koa.response 200, schema: {
|
||||||
|
"milliseconds" => Float64,
|
||||||
|
"titles" => Int32,
|
||||||
|
}
|
||||||
post "/api/admin/scan" do |env|
|
post "/api/admin/scan" do |env|
|
||||||
start = Time.utc
|
start = Time.utc
|
||||||
Library.default.scan
|
Library.default.scan
|
||||||
@ -274,8 +170,10 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Returns the thumbnail generation progress between 0 and 1"
|
Koa.describe "Returns the thumbnail generation progress between 0 and 1"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "library"]
|
||||||
Koa.response 200, ref: "$progressResult"
|
Koa.response 200, schema: {
|
||||||
|
"progress" => Float64,
|
||||||
|
}
|
||||||
get "/api/admin/thumbnail_progress" do |env|
|
get "/api/admin/thumbnail_progress" do |env|
|
||||||
send_json env, {
|
send_json env, {
|
||||||
"progress" => Library.default.thumbnail_generation_progress,
|
"progress" => Library.default.thumbnail_generation_progress,
|
||||||
@ -283,7 +181,7 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Triggers a thumbnail generation"
|
Koa.describe "Triggers a thumbnail generation"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "library"]
|
||||||
post "/api/admin/generate_thumbnails" do |env|
|
post "/api/admin/generate_thumbnails" do |env|
|
||||||
spawn do
|
spawn do
|
||||||
Library.default.generate_thumbnails
|
Library.default.generate_thumbnails
|
||||||
@ -291,8 +189,8 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Deletes a user with `username`"
|
Koa.describe "Deletes a user with `username`"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "users"]
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, schema: "result"
|
||||||
delete "/api/admin/user/delete/:username" do |env|
|
delete "/api/admin/user/delete/:username" do |env|
|
||||||
begin
|
begin
|
||||||
username = env.params.url["username"]
|
username = env.params.url["username"]
|
||||||
@ -319,7 +217,8 @@ struct APIRouter
|
|||||||
Koa.path "tid", desc: "Title ID"
|
Koa.path "tid", desc: "Title ID"
|
||||||
Koa.query "eid", desc: "Entry ID", required: false
|
Koa.query "eid", desc: "Entry ID", required: false
|
||||||
Koa.path "page", desc: "The new page number indicating the progress"
|
Koa.path "page", desc: "The new page number indicating the progress"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, schema: "result"
|
||||||
|
Koa.tag "progress"
|
||||||
put "/api/progress/:tid/:page" do |env|
|
put "/api/progress/:tid/:page" do |env|
|
||||||
begin
|
begin
|
||||||
username = get_username env
|
username = get_username env
|
||||||
@ -350,8 +249,11 @@ struct APIRouter
|
|||||||
Koa.describe "Updates the reading progress of multiple entries in a title"
|
Koa.describe "Updates the reading progress of multiple entries in a title"
|
||||||
Koa.path "action", desc: "The action to perform. Can be either `read` or `unread`"
|
Koa.path "action", desc: "The action to perform. Can be either `read` or `unread`"
|
||||||
Koa.path "tid", desc: "Title ID"
|
Koa.path "tid", desc: "Title ID"
|
||||||
Koa.body ref: "$ids", desc: "An array of entry IDs"
|
Koa.body schema: {
|
||||||
Koa.response 200, ref: "$result"
|
"ids" => [String],
|
||||||
|
}, desc: "An array of entry IDs"
|
||||||
|
Koa.response 200, schema: "result"
|
||||||
|
Koa.tag "progress"
|
||||||
put "/api/bulk_progress/:action/:tid" do |env|
|
put "/api/bulk_progress/:action/:tid" do |env|
|
||||||
begin
|
begin
|
||||||
username = get_username env
|
username = get_username env
|
||||||
@ -377,11 +279,11 @@ struct APIRouter
|
|||||||
Koa.describe "Sets the display name of a title or an entry", <<-MD
|
Koa.describe "Sets the display name of a title or an entry", <<-MD
|
||||||
When `eid` is provided, apply the display name to the entry. Otherwise, apply the display name to the title identified by `tid`.
|
When `eid` is provided, apply the display name to the entry. Otherwise, apply the display name to the title identified by `tid`.
|
||||||
MD
|
MD
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "library"]
|
||||||
Koa.path "tid", desc: "Title ID"
|
Koa.path "tid", desc: "Title ID"
|
||||||
Koa.query "eid", desc: "Entry ID", required: false
|
Koa.query "eid", desc: "Entry ID", required: false
|
||||||
Koa.path "name", desc: "The new display name"
|
Koa.path "name", desc: "The new display name"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, schema: "result"
|
||||||
put "/api/admin/display_name/:tid/:name" do |env|
|
put "/api/admin/display_name/:tid/:name" do |env|
|
||||||
begin
|
begin
|
||||||
title = (Library.default.get_title env.params.url["tid"])
|
title = (Library.default.get_title env.params.url["tid"])
|
||||||
@ -408,9 +310,9 @@ struct APIRouter
|
|||||||
Koa.describe "Returns a MangaDex manga identified by `id`", <<-MD
|
Koa.describe "Returns a MangaDex manga identified by `id`", <<-MD
|
||||||
On error, returns a JSON that contains the error message in the `error` field.
|
On error, returns a JSON that contains the error message in the `error` field.
|
||||||
MD
|
MD
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "mangadex"]
|
||||||
Koa.path "id", desc: "A MangaDex manga ID"
|
Koa.path "id", desc: "A MangaDex manga ID"
|
||||||
Koa.response 200, ref: "$mangadexManga"
|
Koa.response 200, schema: "mdManga"
|
||||||
get "/api/admin/mangadex/manga/:id" do |env|
|
get "/api/admin/mangadex/manga/:id" do |env|
|
||||||
begin
|
begin
|
||||||
id = env.params.url["id"]
|
id = env.params.url["id"]
|
||||||
@ -425,9 +327,14 @@ struct APIRouter
|
|||||||
Koa.describe "Adds a list of MangaDex chapters to the download queue", <<-MD
|
Koa.describe "Adds a list of MangaDex chapters to the download queue", <<-MD
|
||||||
On error, returns a JSON that contains the error message in the `error` field.
|
On error, returns a JSON that contains the error message in the `error` field.
|
||||||
MD
|
MD
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "mangadex", "downloader"]
|
||||||
Koa.body ref: "$chaptersObj"
|
Koa.body schema: {
|
||||||
Koa.response 200, ref: "$successFailCount"
|
"chapters" => ["mdChapter"],
|
||||||
|
}
|
||||||
|
Koa.response 200, schema: {
|
||||||
|
"success" => Int32,
|
||||||
|
"fail" => Int32,
|
||||||
|
}
|
||||||
post "/api/admin/mangadex/download" do |env|
|
post "/api/admin/mangadex/download" do |env|
|
||||||
begin
|
begin
|
||||||
chapters = env.params.json["chapters"].as(Array).map { |c| c.as_h }
|
chapters = env.params.json["chapters"].as(Array).map { |c| c.as_h }
|
||||||
@ -467,8 +374,18 @@ struct APIRouter
|
|||||||
Koa.describe "Returns the current download queue", <<-MD
|
Koa.describe "Returns the current download queue", <<-MD
|
||||||
On error, returns a JSON that contains the error message in the `error` field.
|
On error, returns a JSON that contains the error message in the `error` field.
|
||||||
MD
|
MD
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "downloader"]
|
||||||
Koa.response 200, ref: "$jobs"
|
Koa.response 200, schema: {
|
||||||
|
"success" => Bool,
|
||||||
|
"error" => String?,
|
||||||
|
"paused" => Bool?,
|
||||||
|
"jobs?" => [{
|
||||||
|
"pages" => Int32,
|
||||||
|
"success_count" => Int32,
|
||||||
|
"fail_count" => Int32,
|
||||||
|
"time" => Int64,
|
||||||
|
}.merge(s %w(id manga_id title manga_title status_message status))],
|
||||||
|
}
|
||||||
get "/api/admin/mangadex/queue" do |env|
|
get "/api/admin/mangadex/queue" do |env|
|
||||||
begin
|
begin
|
||||||
jobs = Queue.default.get_all
|
jobs = Queue.default.get_all
|
||||||
@ -494,10 +411,10 @@ struct APIRouter
|
|||||||
|
|
||||||
When `action` is set to `retry`, the behavior depends on `id`. If `id` is provided, restarts the job identified by the ID. Otherwise, retries all jobs in the `Error` or `MissingPages` status in the queue.
|
When `action` is set to `retry`, the behavior depends on `id`. If `id` is provided, restarts the job identified by the ID. Otherwise, retries all jobs in the `Error` or `MissingPages` status in the queue.
|
||||||
MD
|
MD
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "downloader"]
|
||||||
Koa.path "action", desc: "The action to perform. It should be one of the followins: `delete`, `retry`, `pause` and `resume`."
|
Koa.path "action", desc: "The action to perform. It should be one of the followins: `delete`, `retry`, `pause` and `resume`."
|
||||||
Koa.query "id", required: false, desc: "A job ID"
|
Koa.query "id", required: false, desc: "A job ID"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, schema: "result"
|
||||||
post "/api/admin/mangadex/queue/:action" do |env|
|
post "/api/admin/mangadex/queue/:action" do |env|
|
||||||
begin
|
begin
|
||||||
action = env.params.url["action"]
|
action = env.params.url["action"]
|
||||||
@ -546,8 +463,10 @@ struct APIRouter
|
|||||||
When `eid` is omitted, the new cover image will be applied to the title. Otherwise, applies the image to the specified entry.
|
When `eid` is omitted, the new cover image will be applied to the title. Otherwise, applies the image to the specified entry.
|
||||||
MD
|
MD
|
||||||
Koa.tag "admin"
|
Koa.tag "admin"
|
||||||
Koa.body type: "multipart/form-data", ref: "$binaryUpload"
|
Koa.body media_type: "multipart/form-data", schema: {
|
||||||
Koa.response 200, ref: "$result"
|
"file" => Bytes,
|
||||||
|
}
|
||||||
|
Koa.response 200, schema: "result"
|
||||||
post "/api/admin/upload/:target" do |env|
|
post "/api/admin/upload/:target" do |env|
|
||||||
begin
|
begin
|
||||||
target = env.params.url["target"]
|
target = env.params.url["target"]
|
||||||
@ -603,9 +522,18 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Lists the chapters in a title from a plugin"
|
Koa.describe "Lists the chapters in a title from a plugin"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "downloader"]
|
||||||
Koa.body ref: "$pluginListBody"
|
Koa.query "plugin", schema: String
|
||||||
Koa.response 200, ref: "$pluginList"
|
Koa.query "query", schema: String
|
||||||
|
Koa.response 200, schema: {
|
||||||
|
"success" => Bool,
|
||||||
|
"error" => String?,
|
||||||
|
"chapters?" => [{
|
||||||
|
"id" => String,
|
||||||
|
"title" => String,
|
||||||
|
}],
|
||||||
|
"title" => String?,
|
||||||
|
}
|
||||||
get "/api/admin/plugin/list" do |env|
|
get "/api/admin/plugin/list" do |env|
|
||||||
begin
|
begin
|
||||||
query = env.params.query["query"].as String
|
query = env.params.query["query"].as String
|
||||||
@ -629,9 +557,19 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Adds a list of chapters from a plugin to the download queue"
|
Koa.describe "Adds a list of chapters from a plugin to the download queue"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "downloader"]
|
||||||
Koa.body ref: "$pluginDownload"
|
Koa.body schema: {
|
||||||
Koa.response 200, ref: "$successFailCount"
|
"plugin" => String,
|
||||||
|
"title" => String,
|
||||||
|
"chapters" => [{
|
||||||
|
"id" => String,
|
||||||
|
"title" => String,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
Koa.response 200, schema: {
|
||||||
|
"success" => Int32,
|
||||||
|
"fail" => Int32,
|
||||||
|
}
|
||||||
post "/api/admin/plugin/download" do |env|
|
post "/api/admin/plugin/download" do |env|
|
||||||
begin
|
begin
|
||||||
plugin = Plugin.new env.params.json["plugin"].as String
|
plugin = Plugin.new env.params.json["plugin"].as String
|
||||||
@ -664,7 +602,16 @@ struct APIRouter
|
|||||||
Koa.describe "Returns the image dimensions of all pages in an entry"
|
Koa.describe "Returns the image dimensions of all pages in an entry"
|
||||||
Koa.path "tid", desc: "A title ID"
|
Koa.path "tid", desc: "A title ID"
|
||||||
Koa.path "eid", desc: "An entry ID"
|
Koa.path "eid", desc: "An entry ID"
|
||||||
Koa.response 200, ref: "$dimensionResult"
|
Koa.tag "reader"
|
||||||
|
Koa.response 200, schema: {
|
||||||
|
"success" => Bool,
|
||||||
|
"error" => String?,
|
||||||
|
"dimensions?" => [{
|
||||||
|
"width" => Int32,
|
||||||
|
"height" => Int32,
|
||||||
|
}],
|
||||||
|
"margin" => Int32?,
|
||||||
|
}
|
||||||
get "/api/dimensions/:tid/:eid" do |env|
|
get "/api/dimensions/:tid/:eid" do |env|
|
||||||
begin
|
begin
|
||||||
tid = env.params.url["tid"]
|
tid = env.params.url["tid"]
|
||||||
@ -692,8 +639,9 @@ struct APIRouter
|
|||||||
Koa.describe "Downloads an entry"
|
Koa.describe "Downloads an entry"
|
||||||
Koa.path "tid", desc: "A title ID"
|
Koa.path "tid", desc: "A title ID"
|
||||||
Koa.path "eid", desc: "An entry ID"
|
Koa.path "eid", desc: "An entry ID"
|
||||||
Koa.response 200, ref: "$binary"
|
Koa.response 200, schema: Bytes
|
||||||
Koa.response 404, "Entry not found"
|
Koa.response 404, "Entry not found"
|
||||||
|
Koa.tags ["library", "reader"]
|
||||||
get "/api/download/:tid/:eid" do |env|
|
get "/api/download/:tid/:eid" do |env|
|
||||||
begin
|
begin
|
||||||
title = (Library.default.get_title env.params.url["tid"]).not_nil!
|
title = (Library.default.get_title env.params.url["tid"]).not_nil!
|
||||||
@ -708,7 +656,12 @@ struct APIRouter
|
|||||||
|
|
||||||
Koa.describe "Gets the tags of a title"
|
Koa.describe "Gets the tags of a title"
|
||||||
Koa.path "tid", desc: "A title ID"
|
Koa.path "tid", desc: "A title ID"
|
||||||
Koa.response 200, ref: "$tagsResult"
|
Koa.response 200, schema: {
|
||||||
|
"success" => Bool,
|
||||||
|
"error" => String?,
|
||||||
|
"tags" => [String?],
|
||||||
|
}
|
||||||
|
Koa.tags ["library", "tags"]
|
||||||
get "/api/tags/:tid" do |env|
|
get "/api/tags/:tid" do |env|
|
||||||
begin
|
begin
|
||||||
title = (Library.default.get_title env.params.url["tid"]).not_nil!
|
title = (Library.default.get_title env.params.url["tid"]).not_nil!
|
||||||
@ -728,7 +681,12 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Returns all tags"
|
Koa.describe "Returns all tags"
|
||||||
Koa.response 200, ref: "$tagsResult"
|
Koa.response 200, schema: {
|
||||||
|
"success" => Bool,
|
||||||
|
"error" => String?,
|
||||||
|
"tags" => [String?],
|
||||||
|
}
|
||||||
|
Koa.tags ["library", "tags"]
|
||||||
get "/api/tags" do |env|
|
get "/api/tags" do |env|
|
||||||
begin
|
begin
|
||||||
tags = Storage.default.list_tags
|
tags = Storage.default.list_tags
|
||||||
@ -747,8 +705,8 @@ struct APIRouter
|
|||||||
|
|
||||||
Koa.describe "Adds a new tag to a title"
|
Koa.describe "Adds a new tag to a title"
|
||||||
Koa.path "tid", desc: "A title ID"
|
Koa.path "tid", desc: "A title ID"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, schema: "result"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "library", "tags"]
|
||||||
put "/api/admin/tags/:tid/:tag" do |env|
|
put "/api/admin/tags/:tid/:tag" do |env|
|
||||||
begin
|
begin
|
||||||
title = (Library.default.get_title env.params.url["tid"]).not_nil!
|
title = (Library.default.get_title env.params.url["tid"]).not_nil!
|
||||||
@ -770,8 +728,8 @@ struct APIRouter
|
|||||||
|
|
||||||
Koa.describe "Deletes a tag from a title"
|
Koa.describe "Deletes a tag from a title"
|
||||||
Koa.path "tid", desc: "A title ID"
|
Koa.path "tid", desc: "A title ID"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, schema: "result"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "library", "tags"]
|
||||||
delete "/api/admin/tags/:tid/:tag" do |env|
|
delete "/api/admin/tags/:tid/:tag" do |env|
|
||||||
begin
|
begin
|
||||||
title = (Library.default.get_title env.params.url["tid"]).not_nil!
|
title = (Library.default.get_title env.params.url["tid"]).not_nil!
|
||||||
@ -792,8 +750,16 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Lists all missing titles"
|
Koa.describe "Lists all missing titles"
|
||||||
Koa.response 200, ref: "$missingResult"
|
Koa.response 200, schema: {
|
||||||
Koa.tag "admin"
|
"success" => Bool,
|
||||||
|
"error" => String?,
|
||||||
|
"titles?" => [{
|
||||||
|
"path" => String,
|
||||||
|
"id" => String,
|
||||||
|
"signature" => String,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
Koa.tags ["admin", "library"]
|
||||||
get "/api/admin/titles/missing" do |env|
|
get "/api/admin/titles/missing" do |env|
|
||||||
begin
|
begin
|
||||||
send_json env, {
|
send_json env, {
|
||||||
@ -810,8 +776,16 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Lists all missing entries"
|
Koa.describe "Lists all missing entries"
|
||||||
Koa.response 200, ref: "$missingResult"
|
Koa.response 200, schema: {
|
||||||
Koa.tag "admin"
|
"success" => Bool,
|
||||||
|
"error" => String?,
|
||||||
|
"entries?" => [{
|
||||||
|
"path" => String,
|
||||||
|
"id" => String,
|
||||||
|
"signature" => String,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
Koa.tags ["admin", "library"]
|
||||||
get "/api/admin/entries/missing" do |env|
|
get "/api/admin/entries/missing" do |env|
|
||||||
begin
|
begin
|
||||||
send_json env, {
|
send_json env, {
|
||||||
@ -828,8 +802,8 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Deletes all missing titles"
|
Koa.describe "Deletes all missing titles"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, schema: "result"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "library"]
|
||||||
delete "/api/admin/titles/missing" do |env|
|
delete "/api/admin/titles/missing" do |env|
|
||||||
begin
|
begin
|
||||||
Storage.default.delete_missing_title
|
Storage.default.delete_missing_title
|
||||||
@ -846,8 +820,8 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Deletes all missing entries"
|
Koa.describe "Deletes all missing entries"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, schema: "result"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "library"]
|
||||||
delete "/api/admin/entries/missing" do |env|
|
delete "/api/admin/entries/missing" do |env|
|
||||||
begin
|
begin
|
||||||
Storage.default.delete_missing_entry
|
Storage.default.delete_missing_entry
|
||||||
@ -866,8 +840,8 @@ struct APIRouter
|
|||||||
Koa.describe "Deletes a missing title identified by `tid`", <<-MD
|
Koa.describe "Deletes a missing title identified by `tid`", <<-MD
|
||||||
Does nothing if the given `tid` is not found or if the title is not missing.
|
Does nothing if the given `tid` is not found or if the title is not missing.
|
||||||
MD
|
MD
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, schema: "result"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "library"]
|
||||||
delete "/api/admin/titles/missing/:tid" do |env|
|
delete "/api/admin/titles/missing/:tid" do |env|
|
||||||
begin
|
begin
|
||||||
tid = env.params.url["tid"]
|
tid = env.params.url["tid"]
|
||||||
@ -887,8 +861,8 @@ struct APIRouter
|
|||||||
Koa.describe "Deletes a missing entry identified by `eid`", <<-MD
|
Koa.describe "Deletes a missing entry identified by `eid`", <<-MD
|
||||||
Does nothing if the given `eid` is not found or if the entry is not missing.
|
Does nothing if the given `eid` is not found or if the entry is not missing.
|
||||||
MD
|
MD
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, schema: "result"
|
||||||
Koa.tag "admin"
|
Koa.tags ["admin", "library"]
|
||||||
delete "/api/admin/entries/missing/:eid" do |env|
|
delete "/api/admin/entries/missing/:eid" do |env|
|
||||||
begin
|
begin
|
||||||
eid = env.params.url["eid"]
|
eid = env.params.url["eid"]
|
||||||
@ -905,9 +879,19 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Logs the current user into their MangaDex account, and " \
|
Koa.describe "Logs the current user into their MangaDex account", <<-MD
|
||||||
"saves the token."
|
If successful, returns the expiration date (as a unix timestamp) of the newly created token.
|
||||||
Koa.tag "admin"
|
MD
|
||||||
|
Koa.body schema: {
|
||||||
|
"username" => String,
|
||||||
|
"password" => String,
|
||||||
|
}
|
||||||
|
Koa.response 200, schema: {
|
||||||
|
"success" => Bool,
|
||||||
|
"error" => String?,
|
||||||
|
"expires" => Int64?,
|
||||||
|
}
|
||||||
|
Koa.tags ["admin", "mangadex", "users"]
|
||||||
post "/api/admin/mangadex/login" do |env|
|
post "/api/admin/mangadex/login" do |env|
|
||||||
begin
|
begin
|
||||||
username = env.params.json["username"].as String
|
username = env.params.json["username"].as String
|
||||||
@ -934,9 +918,13 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Returns the expiration date of the mangadex token if the " \
|
Koa.describe "Returns the expiration date (as a unix timestamp) of the mangadex token if it exists"
|
||||||
"current user has logged in to MangaDex"
|
Koa.response 200, schema: {
|
||||||
Koa.tag "admin"
|
"success" => Bool,
|
||||||
|
"error" => String?,
|
||||||
|
"expires" => Int64?,
|
||||||
|
}
|
||||||
|
Koa.tags ["admin", "mangadex", "users"]
|
||||||
get "/api/admin/mangadex/expires" do |env|
|
get "/api/admin/mangadex/expires" do |env|
|
||||||
begin
|
begin
|
||||||
username = get_username env
|
username = get_username env
|
||||||
|
Loading…
x
Reference in New Issue
Block a user