- Timestamp:
- Apr 17, 2020, 8:27:38 PM (5 years ago)
- Location:
- devel/pb-server
- Files:
-
- 8 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-server/README
r2293 r2624 4 4 The whole Project-builder.org project is provided under the GPL v2 as per the copying file. 5 5 Other licenses may be available in addition later on. 6 7 Reference docs: 8 https://fr.slideshare.net/ssoriche/metacpan-mojolicious-and-openapi 9 https://mojolicious.io/blog/2017/12/22/day-22-how-to-build-a-public-rest-api/ 10 -
devel/pb-server/bin/pb-server
r2512 r2624 4 4 use warnings; 5 5 6 use lib 'lib';7 6 use ProjectBuilder::Env; 8 7 use ProjectBuilder::Conf; … … 10 9 11 10 # Start command line interface for application 12 require Mojolicious::Commands; 11 use Mojo::File qw(curfile); 12 use lib curfile->dirname->sibling('lib')->to_string; 13 use Mojolicious::Commands; 13 14 14 15 # Force for now 15 16 pb_env_init("pb",undef,"none",0); 17 18 # Debug YAML validation 19 $ENV{'JSON_VALIDATOR_DEBUG'} = 1; 20 16 21 #print "CONF: ".Dumper(pb_conf_get_hash())."\n"; 22 # Start command line interface for application 17 23 Mojolicious::Commands->start_app('ProjectBuilder'); -
devel/pb-server/lib/ProjectBuilder.pm
r2461 r2624 1 1 package ProjectBuilder; 2 2 use Mojo::Base 'Mojolicious'; 3 use ProjectBuilder::Model::Confs; 4 use Data::Dumper; 5 use ProjectBuilder::YAML; 6 use JSON; 3 7 4 use ProjectBuilder::Model::Confs; 5 8 # This method will run once at server start 6 9 sub startup { 7 10 my $self = shift; 8 11 9 # Configuration 10 #$self->secrets([split /:/, $ENV{'BLOG_SECRETS'} || 'super:s3cret']); 11 12 print Dumper($self); 12 13 # Model 13 #$self->helper(pg => sub { state $pg = Mojo::Pg->new($ENV{'BLOG_PG_URL'}) });14 14 $self->helper(confs => sub { state $confs = ProjectBuilder::Model::Confs->new() }); 15 15 16 # Migrate to latest version if necessary 17 #my $path = $self->home->rel_file('migrations/blog.sql'); 18 #$self->pg->migrations->name('blog')->from_file($path)->migrate; 16 # Load configuration from hash returned by config file - doesn't work for now 17 #my $config = $self->plugin('Config' => { file => 'etc/pb-server.json' }); 19 18 20 # Swagger API endpoints 19 # Configure the application 20 #$self->secrets([split /:/, $ENV{'BLOG_SECRETS'} || 'super:s3cret']); 21 #$self->secrets($config->{secrets}); 22 23 # Load Open API endpoins 21 24 # /api * api 22 25 # +/confs POST "store" … … 25 28 # +/confs/(:id) DELETE "remove" 26 29 # +/confs/(:id) GET "show" 27 $self->plugin(openapi => {url => $self->home->rel_file('api.yml')}); 30 my $c = { 31 #schema => "v3", 32 default_response_codes => [400, 401, 404, 500, 501], 33 #default_response_name => 1, 34 url => 'file:///usr/share/pb/api.yaml', 35 }; 36 $self->plugin(OpenAPI => $c); 37 print "After Plugin OpenAPI\n"; 38 #$self->plugin(OpenAPI => {schema_file => $self->home->rel_file('api.yaml'), schema => "v3"}); 28 39 29 40 # Regular web pages … … 36 47 # /confs/:id PUT "update_conf" 37 48 # /confs/:id DELETE "remove_conf" 49 50 # Router 38 51 my $r = $self->routes; 52 53 # Normal route to controller 54 $r->get('/w')->to('example#welcome'); 39 55 $r->get('/' => sub { shift->redirect_to('confs') }); 40 56 $r->get('/confs')->to('conf#list'); … … 48 64 # Swagger2 module not maintained anymore 49 65 #require Swagger2::Editor; 50 #my $editor = Swagger2::Editor->new(specification_file => $self->home->rel_file('api.y ml'));66 #my $editor = Swagger2::Editor->new(specification_file => $self->home->rel_file('api.yaml')); 51 67 #$r->route('/editor')->detour(app => $editor); 52 68 }
Note:
See TracChangeset
for help on using the changeset viewer.