diff --git a/PostText.pl b/PostText.pl index 3cedec3..b5e53e7 100755 --- a/PostText.pl +++ b/PostText.pl @@ -4,6 +4,26 @@ # Jul 22 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 get '/', sub ($c) { $c->redirect_to('view') }; @@ -12,4 +32,6 @@ get '/view', sub ($c) { $c->render() }; +app->secrets(app->config->{'secrets'}) || die $@; + app->start(); diff --git a/README.md b/README.md index 2830e14..347dc50 100644 --- a/README.md +++ b/README.md @@ -24,5 +24,6 @@ Run the tests locally (against development environment) ## TODOs -1. Where is prototype lmao +1. Moar tests... +1. Need migrations for PostText::Model::Thread 1. Implement threads diff --git a/cpanfile b/cpanfile index 2e82d7b..24a65db 100644 --- a/cpanfile +++ b/cpanfile @@ -1 +1,2 @@ requires 'Mojolicious'; +requires 'Mojo::Pg'; diff --git a/lib/PostText/Model/Thread.pm b/lib/PostText/Model/Thread.pm index e69de29..07b7483 100644 --- a/lib/PostText/Model/Thread.pm +++ b/lib/PostText/Model/Thread.pm @@ -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; diff --git a/t/root.t b/t/root.t index 66dd8c4..f58f36d 100644 --- a/t/root.t +++ b/t/root.t @@ -9,6 +9,6 @@ use Test::Mojo; my $script = curfile->dirname->sibling('PostText.pl'); my $t = Test::Mojo->new($script); -$t->get_ok('/')->status_is(200); +$t->get_ok('/')->status_is(302); done_testing();