diff --git a/lib/MetaCPAN/API.pm b/lib/MetaCPAN/API.pm index dda3a1814..d5537664a 100644 --- a/lib/MetaCPAN/API.pm +++ b/lib/MetaCPAN/API.pm @@ -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}; diff --git a/t/lib/MetaCPAN/TestServer.pm b/t/lib/MetaCPAN/TestServer.pm index 69328084b..bdc051aa5 100644 --- a/t/lib/MetaCPAN/TestServer.pm +++ b/t/lib/MetaCPAN/TestServer.pm @@ -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' );