source: ProjectBuilder/devel/pb-server/lib/ProjectBuilder.pm@ 2461

Last change on this file since 2461 was 2461, checked in by Bruno Cornec, 4 years ago

Remove swagger2 module dep as not maintained anymore

File size: 1.9 KB
Line 
1package ProjectBuilder;
2use Mojo::Base 'Mojolicious';
3
4use ProjectBuilder::Model::Confs;
5
6sub startup {
7 my $self = shift;
8
9 # Configuration
10 #$self->secrets([split /:/, $ENV{'BLOG_SECRETS'} || 'super:s3cret']);
11
12 # Model
13 #$self->helper(pg => sub { state $pg = Mojo::Pg->new($ENV{'BLOG_PG_URL'}) });
14 $self->helper(confs => sub { state $confs = ProjectBuilder::Model::Confs->new() });
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;
19
20 # Swagger API endpoints
21 # /api * api
22 # +/confs POST "store"
23 # +/confs GET "list"
24 # +/confs/(:id) PUT "update"
25 # +/confs/(:id) DELETE "remove"
26 # +/confs/(:id) GET "show"
27 $self->plugin(openapi => {url => $self->home->rel_file('api.yml')});
28
29 # Regular web pages
30 # / GET
31 # /confs GET confs
32 # /confs/create GET "create_conf"
33 # /confs POST "store_conf"
34 # /confs/:id GET "show_conf"
35 # /confs/:id/edit GET "edit_conf"
36 # /confs/:id PUT "update_conf"
37 # /confs/:id DELETE "remove_conf"
38 my $r = $self->routes;
39 $r->get('/' => sub { shift->redirect_to('confs') });
40 $r->get('/confs')->to('conf#list');
41 $r->get('/confs/create')->to('conf#create')->name('create_conf');
42 $r->post('/confs')->to('conf#store')->name('store_conf');
43 $r->get('/confs/:id')->to('conf#show')->name('show_conf');
44 $r->get('/confs/:id/edit')->to('conf#edit')->name('edit_conf');
45 $r->put('/confs/:id')->to('conf#update')->name('update_conf');
46 $r->delete('/conconfid')->to('conf#remove')->name('remove_conf');
47
48 # Swagger2 module not maintained anymore
49 #require Swagger2::Editor;
50 #my $editor = Swagger2::Editor->new(specification_file => $self->home->rel_file('api.yml'));
51 #$r->route('/editor')->detour(app => $editor);
52}
53
541;
Note: See TracBrowser for help on using the repository browser.