Compare commits

...

4 Commits

Author SHA1 Message Date
984438729e docs: update readme 2025-12-18 07:28:59 +01:00
1e8bfc2ac0 build: update cpan.snapshot 2025-12-18 07:28:46 +01:00
1148a65355 build: add Mojo::Redis2 as a requirement 2025-12-18 07:28:41 +01:00
acb1f63bae feat: add a dummy set/get in the main route to try redis 2025-12-18 07:28:24 +01:00
4 changed files with 58 additions and 4 deletions

View File

@@ -11,7 +11,7 @@
## Roadmap
- [x] create installation script
- [ ] connect to redis
- [x] connect to redis + setter and getter operations
- [ ] create dummy API endpoints
- [ ] decide how to handle short url generation
- [ ] avoid collisions in short urls

View File

@@ -1,2 +1,3 @@
requires 'Mojolicious', '>= 9.0';
requires 'Moose';
requires 'Mojo::Redis2';

View File

@@ -141,6 +141,20 @@ DISTRIBUTIONS
perl 5.006
strict 0
warnings 0
Mojo-Redis2-0.32
pathname: D/DB/DBOOK/Mojo-Redis2-0.32.tar.gz
provides:
Mojo::Redis2 0.32
Mojo::Redis2::Backend undef
Mojo::Redis2::Bulk undef
Mojo::Redis2::Client undef
Mojo::Redis2::Cursor undef
Mojo::Redis2::Server undef
Mojo::Redis2::Transaction 0.01
requirements:
ExtUtils::MakeMaker 0
Mojolicious 7.50
Protocol::Redis 1.0
Mojolicious-9.42
pathname: S/SR/SRI/Mojolicious-9.42.tar.gz
provides:
@@ -787,6 +801,16 @@ DISTRIBUTIONS
Scalar::Util 1.18
XSLoader 0.22
parent 0
Protocol-Redis-1.0021
pathname: U/UN/UNDEF/Protocol-Redis-1.0021.tar.gz
provides:
Protocol::Redis 1.0021
Protocol::Redis::Test undef
requirements:
Carp 0
ExtUtils::MakeMaker 0
Test::More 0.94
perl 5.008001
Sub-Exporter-0.991
pathname: R/RJ/RJBS/Sub-Exporter-0.991.tar.gz
provides:

View File

@@ -1,16 +1,45 @@
package Urupam::App;
use Mojo::Base 'Mojolicious';
use Moose;
use Urupam::DB;
sub startup {
my $self = shift;
$self->helper(
db => sub {
my $c = shift;
$c->stash->{db} ||= Urupam::DB->new;
}
);
my $r = $self->routes;
$r->get('/')->to(
cb => sub {
my $c = shift;
$c->render( text => 'Hello from urupam!' );
my $tx = $c->render_later->tx;
my $db = $c->db;
$db->set( 'test_key' => '123soleil' )->then(
sub {
$c->app->log->info('Value set: test_key => 123soleil');
return $db->get('test_key');
}
)->then(
sub {
my $value = shift;
$c->app->log->info("Value retrieved: $value");
$c->render( text => "ok\nRetrieved value: $value" );
undef $tx;
}
)->catch(
sub {
my $err = shift;
$c->app->log->error("DB error: $err");
$c->render( text => "ok\nError: $err", status => 500 );
undef $tx;
}
);
}
);
}