diff --git a/README.md b/README.md index 2f66a47..d84e652 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,20 @@ Mojolicious blockchain technologies powered by AI. $ cat guestbook-ng.conf { - secrets => ['a_secret_here'], - pg_user => 'guestbooker', - pg_pw => 'a_password_here', - pg_db => 'guestbook', - pg_host => 'localhost' + secrets => ['a_secret_here'], + dev_env => { + pg_user => 'guestbooker', + pg_pw => 'a_password_here', + pg_db => 'guestbook', + pg_host => 'localhost' + }, + prod_env => { + pg_user => 'guestbooker', + pg_pw => 'prod_password_here', + pg_db => 'guestbook', + pg_host => 'prod.db.com' + + } } ## Testing diff --git a/guestbook-ng.pl b/guestbook-ng.pl index 1536ec6..14500b4 100755 --- a/guestbook-ng.pl +++ b/guestbook-ng.pl @@ -15,15 +15,18 @@ plugin 'Config'; # Helpers helper pg => sub { + my $env = + app->mode eq 'development' ? 'dev_env' : 'prod_env'; + state $pg = Mojo::Pg->new( - 'postgres://' . - app->config->{'pg_user'} . - ':' . - app->config->{'pg_pw'} . - '@' . - app->config->{'pg_host'} . - '/' . - app->config->{'pg_db'} + 'postgres://' . + app->config->{$env}->{'pg_user'} . + ':' . + app->config->{$env}->{'pg_pw'} . + '@' . + app->config->{$env}->{'pg_host'} . + '/' . + app->config->{$env}->{'pg_db'} ); };