@@ -2,19 +2,11 @@ package MetaCPAN::API;
22
33=head1 DESCRIPTION
44
5- This is the API web server interface.
6-
7- # On vagrant VM
8- ./bin/run morbo bin/api.pl
5+ This is the API Minion server.
96
107 # Display information on jobs in queue
118 ./bin/run bin/api.pl minion job -s
129
13- To run the api web server, run the following on one of the servers:
14-
15- # Run the daemon on a local port (tunnel to display on your browser)
16- ./bin/run bin/api.pl daemon
17-
1810=cut
1911
2012use Mojo::Base ' Mojolicious' ;
@@ -24,12 +16,6 @@ use List::Util qw( any );
2416use MetaCPAN::Script::Runner ();
2517use Try::Tiny qw( catch try ) ;
2618use MetaCPAN::Server::Config ();
27- use MetaCPAN::Types::TypeTiny qw( ES ) ;
28-
29- has es => sub {
30- ES-> assert_coerce(
31- MetaCPAN::Server::Config::config()-> {elasticsearch_servers } );
32- };
3319
3420sub startup {
3521 my $self = shift ;
@@ -55,7 +41,6 @@ sub startup {
5541 $self -> minion-> add_task(
5642 index_favorite => $self -> _gen_index_task_sub(' favorite' ) );
5743
58- $self -> plugin(' MetaCPAN::API::Plugin::Model' );
5944 $self -> _set_up_routes;
6045}
6146
@@ -127,25 +112,6 @@ sub _set_up_routes {
127112 -> name(' identity_search_form' );
128113
129114 $self -> plugin( ' Minion::Admin' => { route => $admin -> any(' /minion' ) } );
130- $self -> plugin(
131- ' OpenAPI' => { url => $self -> home-> rel_file(' root/static/v1.yml' ) } );
132-
133- # This route is for when nginx gets updated to no longer strip the `/v1` path.
134- # By retaining the `/v1` path the OpenAPI spec is picked up and passed
135- # through Mojolicous. The `rewrite` parameter is stripping the `/v1` before
136- # it is passed to Catalyst allowing the previous logic to be followed.
137- $self -> plugin(
138- MountPSGI => {
139- ' /v1' => $self -> home-> child(' app.psgi' )-> to_string,
140- rewrite => 1
141- }
142- );
143-
144- # XXX Catch cases when `v1` has been stripped by nginx until migration is complete
145- # XXX then this path can be removed.
146- $self -> plugin(
147- MountPSGI => { ' /' => $self -> home-> child(' app.psgi' )-> to_string } );
148-
149115}
150116
151117sub _is_admin {
@@ -205,43 +171,12 @@ sub _set_up_oauth_routes {
205171 $c -> session( is_logged_in => 1 );
206172 $c -> session( github_username => $username );
207173 if ( $self -> _is_admin($username ) ) {
208- $c -> session( github_username => $username );
209174 $c -> redirect_to(' /admin' );
210175 return ;
211176 }
212177 $c -> redirect_to( $self -> config-> {front_end_url } );
213178 },
214179 );
215-
216- $self -> plugin(
217- ' Web::Auth' ,
218- module => ' Google' ,
219- key => $oauth -> {google }-> {key },
220- secret => $oauth -> {google }-> {secret },
221- user_info => 1,
222- on_finished => sub {
223- my ( $c , $access_token , $account_info ) = @_ ;
224- my $username = $account_info -> {login };
225- $c -> session( is_logged_in => 1 );
226- $c -> session( google_username => $username );
227- $c -> redirect_to( $self -> config-> {front_end_url } );
228- },
229- );
230-
231- $self -> plugin(
232- ' Web::Auth' ,
233- module => ' Twitter' ,
234- key => $oauth -> {twitter }-> {key },
235- secret => $oauth -> {twitter }-> {secret },
236- user_info => 1,
237- on_finished => sub {
238- my ( $c , $access_token , $access_secret , $account_info ) = @_ ;
239- my $username = $account_info -> {screen_name };
240- $c -> session( is_logged_in => 1 );
241- $c -> session( twitter_username => $username );
242- $c -> redirect_to( $self -> config-> {front_end_url } );
243- },
244- );
245180}
246181
2471821;
0 commit comments