OwlcodeAds/lib/OwlcodeAds.pm
2023-08-02 16:19:44 +02:00

49 lines
1.1 KiB
Perl

package OwlcodeAds;
use v5.36.0;
use strict;
use warnings;
use utf8;
use Mojo::Base 'Mojolicious', -signatures;
# This method will run once at server start
sub startup ($self) {
my $sessions = Mojolicious::Sessions->new;
$sessions->cookie_name('OwlcodeAds');
$sessions->default_expiration(0);
$self->sessions($sessions);
# Load configuration from config file
my $config = $self->plugin('NotYAMLConfig');
# Configure the application
$self->secrets( $config->{secrets} );
# Router
my $r = $self->routes;
# Normal route to controller
{
my $api = $r->any('/api');
{
my $user = $api->any('/user');
$user->post('/')->to('Register#register');
}
$api->any(
'/*' => sub ($c) {
$c->render(
status => 404,
json => {
error => 'Enpoint not found.'
}
);
}
);
}
$r->get('/*')->to('React#react');
$r->get('/')->to('React#react');
}
1;