api, backend: whitespace and declarations shuffling

This commit is contained in:
Lucas 2023-02-19 18:14:04 +00:00
parent 06a939bcd1
commit 065d5a9d88
2 changed files with 13 additions and 5 deletions

View File

@ -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;

View File

@ -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" },