Just specify Postgres connection string in conf file

This commit is contained in:
swagg boi 2022-01-10 14:18:49 -05:00
parent 467854df49
commit 681ed961e8
2 changed files with 11 additions and 27 deletions

View file

@ -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 => '<strong>{current}</strong>'
separator => '',
current => '<strong><u>{current}</u></strong>',
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

View file

@ -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 {