From 681ed961e8f2412ae952cdcbaf8137ff085958ad Mon Sep 17 00:00:00 2001 From: swag Date: Mon, 10 Jan 2022 14:18:49 -0500 Subject: [PATCH] Just specify Postgres connection string in conf file --- README.md | 24 +++++++++--------------- guestbook-ng.pl | 14 ++------------ 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index cd197b6..ca0f937 100644 --- a/README.md +++ b/README.md @@ -8,28 +8,24 @@ Mojolicious blockchain technologies powered by AI. $ cat guestbook-ng.conf { - secrets => ['a_secret_here'], + secrets => ['secret_goes_here'], 'TagHelpers-Pagination' => { - separator => ' ', - current => '{current}' + separator => '', + current => '{current}', + next => 'Next', + prev => 'Prev', + ellipsis => '..' }, dev_env => { - pg_user => 'guestbooker', - pg_pw => 'a_password_here', - pg_db => 'guestbook', - pg_host => 'localhost' + pg_string => 'postgresql://user:PASSWORD@example.com/db' }, prod_env => { - pg_user => 'guestbooker', - pg_pw => 'prod_password_here', - pg_db => 'guestbook', - pg_host => 'prod.db.com' - + pg_string => 'postgresql://user:PASSWORD@example.com/db' }, max_posts => 5 } -`secrets` and the DB credentials are mandatory +`secrets` and the Postgres connection string are mandatory ## Testing @@ -58,7 +54,5 @@ Add the `-v` option for more verbose output ## TODOs -1. Make the Postgres connection string more configurable (need to use - UNIX sockets in Prod...) 1. /spam route would be interesting 1. Include the total number of visitors or messages diff --git a/guestbook-ng.pl b/guestbook-ng.pl index 0ad694c..c1418ab 100755 --- a/guestbook-ng.pl +++ b/guestbook-ng.pl @@ -20,18 +20,8 @@ plugin AssetPack => {pipes => [qw{Css JavaScript Combine}]}; # Helpers helper pg => sub { - my $env = app->mode() eq 'development' ? 'dev_env' : 'prod_env'; - - state $pg = Mojo::Pg->new( - 'postgres://' . - app->config->{$env}{'pg_user'} . - ':' . - app->config->{$env}{'pg_pw'} . - '@' . - app->config->{$env}{'pg_host'} . - '/' . - app->config->{$env}{'pg_db'} - ); + my $env = app->mode() eq 'development' ? 'dev_env' : 'prod_env'; + state $pg = Mojo::Pg->new(app->config->{$env}{'pg_string'}); }; helper message => sub {