# {% name %}

A [Punk](https://metacpan.org/pod/Punk) application.

## Run it

    plackup app.psgi

or, on the event-loop server Punk is built for:

    hyperman app.psgi

Then open <http://localhost:5000/>.

## Test it

    prove -l t/

## Layout

    lib/{% path %}.pm                     routes and wiring
    lib/{% path %}/Controller/Web/Root.pm the front page
{% if api %}    lib/{% path %}/Controller/API/        one class per API tag, stubs to fill in
    openapi.json                      the API contract; routing and validation
                                      both come from it
{% end %}    config/punk.yml                   views, database, plugins, secrets
    root/templates/                   Stencil templates
    root/static/                      files served at /static

## Where to go next

Add a route in `lib/{% path %}.pm`:

    get '/hello/:name' => sub {
        my ($c) = @_;
        return $c->text('hello ' . $c->param('name'));
    };

Add a model - declare the connection in `config/punk.yml`, then:

    # lib/{% path %}/Model/Thing.pm
    package {% name %}::Model::Thing;
    use Punk::Model;

    table 'things';
    field id    => { type => 'integer' };
    field title => { type => 'string', required => 1 };

Models under `{% name %}::Model::` are discovered automatically; reach one
with `$c->model('Thing')`.
{% if api %}
Implement an operation by filling in the stub whose name matches its
`operationId`. Validated parameters and body arrive in `$c->openapi`, and
`$c->param` reads them first.
{% end %}
See `perldoc Punk` for the full keyword list.
