diff --git a/lib/PoorBooru.pm b/lib/PoorBooru.pm index 5b93736..78f7011 100644 --- a/lib/PoorBooru.pm +++ b/lib/PoorBooru.pm @@ -1,11 +1,14 @@ package PoorBooru; +use v5.32; use Dancer2; use HTTP::Tiny; + our $VERSION = v0.0.1; my $POORBOORU_API = setting("poorbooru_api"); + sub validate_page_number ($) { $_[0] =~ /^[1-9][0-9]*$/ } sub api_request ($$;%) @@ -50,6 +53,7 @@ sub nav_pager ($$) return \%res; } + hook before_template_render => sub { my $tokens = shift; diff --git a/lib/PoorBooru/API/V0.pm b/lib/PoorBooru/API/V0.pm index b5b27e3..8105797 100644 --- a/lib/PoorBooru/API/V0.pm +++ b/lib/PoorBooru/API/V0.pm @@ -1,17 +1,14 @@ package PoorBooru::API::V0; +use v5.32; use Dancer2; use Dancer2::Plugin::DBIC; -our $VERSION = v0.0.1; - -set serializer => "JSON"; use constant { DEFAULT_CONTENT_TYPE => "application/json", }; -sub validate_page_number ($) { $_[0] =~ /^[1-9][0-9]*$/ } -sub validate_tag_name ($) { $_[0] !~ /^[1-9][0-9]*$/ && $_[0] =~ /^\w+$/ } +our $VERSION = v0.0.1; my $MEDIA_SEARCH_OPTS = { order_by => { -desc => "media_id" }, @@ -23,6 +20,9 @@ my $TAGS_COUNT_VIEW_SEARCH_OPTS = { }; +sub validate_page_number ($) { $_[0] =~ /^[1-9][0-9]*$/ } +sub validate_tag_name ($) { $_[0] !~ /^[1-9][0-9]*$/ && $_[0] =~ /^\w+$/ } + sub mkpager ($) { my $pager = $_[0]->pager; @@ -35,6 +35,10 @@ sub mkpager ($) }; } + +set serializer => "JSON"; + + get "/meta" => sub { return [ { path => "/meta", verb => "GET" },