api: initial migration
This commit is contained in:
parent
13a6d287af
commit
7ccbc3af12
8 changed files with 190 additions and 0 deletions
29
lib/PoorBooru/API/V0.pm
Normal file
29
lib/PoorBooru/API/V0.pm
Normal file
|
@ -0,0 +1,29 @@
|
|||
package PoorBooru::API::V0;
|
||||
use v5.36;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Mojo::Base "Mojolicious";
|
||||
|
||||
use PoorBooru::Schema;
|
||||
|
||||
sub startup ($self)
|
||||
{
|
||||
$self->moniker("poorbooru-api-v0");
|
||||
|
||||
my $config = $self->plugin("Config");
|
||||
$self->secrets($config->{secrets});
|
||||
|
||||
$self->helper(schema => sub {
|
||||
state $schema = PoorBooru::Schema->connect($config->{dsn})
|
||||
});
|
||||
|
||||
my $r = $self->routes;
|
||||
|
||||
$r->get("/meta")->to("meta#index");
|
||||
|
||||
$r->get("/tags")->to("tags#list");
|
||||
$r->get("/tag/:tag_id_or_name")->to("tags#show");
|
||||
}
|
||||
|
||||
1;
|
Reference in a new issue