[2077] | 1 | package ProjectBuilder;
|
---|
| 2 | use Mojo::Base 'Mojolicious';
|
---|
| 3 |
|
---|
| 4 | use ProjectBuilder::Model::Confs;
|
---|
| 5 |
|
---|
| 6 | sub startup {
|
---|
| 7 | my $self = shift;
|
---|
| 8 |
|
---|
| 9 | # Configuration
|
---|
[2287] | 10 | #$self->secrets([split /:/, $ENV{'BLOG_SECRETS'} || 'super:s3cret']);
|
---|
[2077] | 11 |
|
---|
| 12 | # Model
|
---|
[2287] | 13 | #$self->helper(pg => sub { state $pg = Mojo::Pg->new($ENV{'BLOG_PG_URL'}) });
|
---|
[2077] | 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"
|
---|
[2461] | 27 | $self->plugin(openapi => {url => $self->home->rel_file('api.yml')});
|
---|
[2077] | 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 |
|
---|
[2461] | 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);
|
---|
[2077] | 52 | }
|
---|
| 53 |
|
---|
| 54 | 1;
|
---|