Implement Thread model

This commit is contained in:
swagg boi 2022-07-28 21:13:26 -04:00
parent 98a44773d5
commit 7eb6d2d37e
5 changed files with 39 additions and 2 deletions

View file

@ -4,6 +4,26 @@
# Jul 22 # Jul 22
use Mojolicious::Lite -signatures; use Mojolicious::Lite -signatures;
use Mojo::Pg;
# Load the local modules too
use lib 'lib';
use PostText::Model::Thread;
# Load Mojo plugins
plugin 'Config';
# Helpers
helper pg => sub {
state $pg = Mojo::Pg->new(app->config->{app->mode}{'pg_string'})
};
# Begin routing
under sub ($c) {
$c->session(expires => time() + 1800);
1;
};
# Root redirect # Root redirect
get '/', sub ($c) { $c->redirect_to('view') }; get '/', sub ($c) { $c->redirect_to('view') };
@ -12,4 +32,6 @@ get '/view', sub ($c) {
$c->render() $c->render()
}; };
app->secrets(app->config->{'secrets'}) || die $@;
app->start(); app->start();

View file

@ -24,5 +24,6 @@ Run the tests locally (against development environment)
## TODOs ## TODOs
1. Where is prototype lmao 1. Moar tests...
1. Need migrations for PostText::Model::Thread
1. Implement threads 1. Implement threads

View file

@ -1 +1,2 @@
requires 'Mojolicious'; requires 'Mojolicious';
requires 'Mojo::Pg';

View file

@ -0,0 +1,13 @@
#!/usr/bin/env perl
package PostText::Model::Thread;
use Mojo::Base -base, -signatures;
has 'pg';
sub new($class, $pg, $pg_object) {
bless {$pg => $pg_object}
}
1;

View file

@ -9,6 +9,6 @@ use Test::Mojo;
my $script = curfile->dirname->sibling('PostText.pl'); my $script = curfile->dirname->sibling('PostText.pl');
my $t = Test::Mojo->new($script); my $t = Test::Mojo->new($script);
$t->get_ok('/')->status_is(200); $t->get_ok('/')->status_is(302);
done_testing(); done_testing();