NAME

Developer::Dashboard::Web::App - local web application for Developer Dashboard

SYNOPSIS

my $app = Developer::Dashboard::Web::App->new(
    auth     => $auth,
    pages    => $pages,
    sessions => $sessions,
);

DESCRIPTION

This module handles the browser-facing dashboard routes, helper login flow, page rendering modes, and page/action execution endpoints. It also provides static file serving for JavaScript, CSS, and other assets from the public directory structure (~/.developer-dashboard/dashboard/public/{js,css,others}).

METHODS

new, handle

Construct and dispatch the local web application.

_serve_static_file($type, $filename)

Serves static files from the public directory.

Input: $type (js, css, or others subdirectory), $filename (requested filename). Output: array reference of [status_code, content_type, body].

Security: Prevents directory traversal attacks and verifies files are within the public directory before serving.

_get_content_type($type, $filename)

Determines the MIME type for a file based on its type and extension.

Input: $type (js, css, or others), $filename (requested filename). Output: MIME type string suitable for Content-Type header.

Supports: JS, CSS, JSON, XML, HTML, SVG, PNG, JPEG, GIF, WebP, ICO, and others.

PURPOSE

This module is the main route backend for the browser application. It handles login and logout, saved and transient page render/source/edit routes, status endpoints, saved Ajax endpoints, API dashboard and SQL dashboard routes, and the auth checks that decide whether a request is local admin, helper user, or unauthorized outsider.

WHY IT EXISTS

It exists because the dashboard browser surface is large and security-sensitive. Centralizing route behavior, auth gating, saved-page handling, Ajax endpoints, and response shaping keeps the product behavior coherent and testable.

WHEN TO USE

Use this file when changing browser routes, helper login behavior, page render/source/edit flows, saved Ajax endpoints, or the runtime JSON and HTML responses for dashboard workspaces.

HOW TO USE

Construct it with the action runner, auth service, page store, prompt, page resolver, page runtime, and session store, then hand it to the Dancer adapter or PSGI bootstrap. Route-specific behavior belongs here rather than in the transport wrapper.

WHAT USES IT

It is used by Developer::Dashboard::Web::DancerApp, by app.psgi, by the CLI web server wrapper, and by the broad web/browser regression suite that covers routes, auth, Ajax, and workspace behavior.

EXAMPLES

Example 1:

perl -Ilib -MDeveloper::Dashboard::Web::App -e 1

Do a direct compile-and-load check against the module from a source checkout.

Example 2:

prove -lv t/03-web-app.t t/08-web-update-coverage.t t/web_app_static_files.t

Run the focused regression tests that most directly exercise this module's behavior.

Example 3:

HARNESS_PERL_SWITCHES=-MDevel::Cover prove -lr t

Recheck the module under the repository coverage gate rather than relying on a load-only probe.

Example 4:

prove -lr t

Put any module-level change back through the entire repository suite before release.