Skip to content

Commit

Permalink
Mojo: use MetaCPAN::Server::Config
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed Oct 25, 2024
1 parent e134d2c commit 1cb2a0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
27 changes: 10 additions & 17 deletions lib/MetaCPAN/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,24 @@ To run the api web server, run the following on one of the servers:

use Mojo::Base 'Mojolicious';

use Config::ZOMG ();
use File::Temp ();
use List::Util qw( any );
use MetaCPAN::Script::Runner ();
use Search::Elasticsearch ();
use Try::Tiny qw( catch try );
use File::Temp ();
use List::Util qw( any );
use MetaCPAN::Script::Runner ();
use Search::Elasticsearch ();
use Try::Tiny qw( catch try );
use MetaCPAN::Server::Config ();
use MooseX::Types::ElasticSearch qw(ES);

has es => sub {
return Search::Elasticsearch->new(
client => '2_0::Direct',
( $ENV{ES} ? ( nodes => [ $ENV{ES} ] ) : () ),
);
ES->assert_coerce(
MetaCPAN::Server::Config::config()->{elasticsearch_servers} );
};

sub startup {
my $self = shift;

unless ( $self->config->{config_override} ) {
$self->config(
Config::ZOMG->new(
local_suffix => $ENV{HARNESS_ACTIVE} ? 'testing' : 'local',
name => 'metacpan_server',
path => $self->home->to_string,
)->load
);
$self->config( MetaCPAN::Server::Config::config() );
}

die 'need secret' unless $self->config->{secret};
Expand Down
2 changes: 1 addition & 1 deletion t/lib/MetaCPAN/TestServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ sub _build_config {
sub _build_es_client {
my $self = shift;

my $es = ES->coerce(
my $es = ES->assert_coerce(
MetaCPAN::Server::Config::config()->{elasticsearch_servers}, );

ok( $es, 'got Search::Elasticsearch object' );
Expand Down

0 comments on commit 1cb2a0f

Please sign in to comment.