STAXIS

staxis js platform -> gitlab project
staxis on gitlab gitlab project 🏷️ V-0.X-Beta
We’re actively updating this manual. Content and layout may change as we refine it.

httpKindness

Official sources are open to Staxis GitLab group members: how to join and view the code.
Repository: httpKindness development
Versions: tags and releases


Description

httpKindness supplies HTML fallback pages for requests left unresolved by the normal application. Its label and typology are both httpKindness. It selects a page from the current error status, supports optional favicon suppression and URL bypass rules, and can redirect to the public error-page URL instead of serving the HTML in place.


Read before flight

  • We suggest registering httpKindness after ordinary routes, rendering, static delivery, and downloads, before httpListener. Keep config.serveropt.safeEnd=false so the native application leaves unresolved responses available for the fallback handler.

  • We suggest keeping both 404.html and 500.html available and adding pages for the other statuses your application uses. Keep their contents suitable for public viewing and avoid exposing internal exception details.

  • We suggest serving fallback HTML in place for ordinary use. Reserve redirect mode for deployments where the destination error-page URL is independently served. For APIs and downloads, choose bypass rules that match their real URLs and keep response completion in the relevant application handler.


Requirements and Installation

The required pack is serverApp, whose supplied manifest already permits httpKindness's pack label. No extra npm dependency is required. The ppm library supplies notKindness pattern matching when available; keep it before this pack if you use bypass rules. Install through the Manager:

                manager -> install -> httpKindness
            

Prepare the project keys and integrity records, create the fallback pages, and check the final merged configuration before startup. Normal use needs no consumer Vault request to httpKindness. It obtains serverApp internally and registers its handler through using.


Files Map

File Purpose
manifest.json Declares the pack identity and serverApp requirement
configs.js Provides safeEnd, the kindness folder, bypass settings, and Guardian file-access rules
main.js Registers fallback handling, selects status pages, and implements favicon suppression
README.md Pack reference and fallback-page layout

Configuration

In the project's config.js, behaviour flags belong directly to config.serveropt, folder names to config.serveropt.folders, and file permissions to config.engineopt.guard.allowedFileAccess. Merge the following branches into the exported config object, preserving other folders and Guardian rules.

                // config.js -> config (merge into the exported object)
                engineopt: {
                    guard: {
                        allowedFileAccess: [
                            {
                                pack: 'httpKindness', // Pack label used by Guardian
                                roots: [
                                    './server-public/kindness',
                                    './server-public/kindness/*'
                                ]
                            }
                        ]
                    }
                },
                serveropt: {
                    safeEnd: false,
                    folders: {
                        public: 'server-public',
                        kindness: 'kindness'
                    },
                    nofavicon: true,
                    notKindness: ['download'],
                    forceKRedirect: false
                }
            

The example uses download to match httpDownloads's default alias. The supplied httpKindness configuration uses downloads instead; align that value with your own download URL. The public folder is shown explicitly so this example does not depend on another pack adding it. If you change either folder, update the Guardian roots too.

Option under config.serveropt Behaviour
safeEnd=falseLeaves native unresolved responses open for fallback handling
folders.publicPublic-tree folder used to locate the kindness directory
folders.kindnessFallback-page directory beneath the public tree; supplied as kindness
nofavicon=trueReturns 204 for /favicon.ico when that request reaches this handler
notKindnessPPM pathname patterns that bypass fallback rendering
forceKRedirect=falseServes the selected HTML in place; true selects a 302 redirect

serverApp normally supplies safeEnd=true. httpKindness supplies false, and logs a warning if the final merged value is not false. Check the resulting config.js rather than assuming pack defaults have combined in the desired order.


Create the Fallback Pages

                project-root/
                └── server-public/
                    └── kindness/
                        β”œβ”€β”€ 404.html
                        β”œβ”€β”€ 500.html
                        └── 403.html
            

Create 404.html and 500.html first; 403.html illustrates an additional status-specific page. These are HTML files read by the pack, not templates rendered through viewEngine. With the standard pack layout, file paths are resolved through engine.fileaccess from the configured public and kindness folders. The response uses text/html; charset=utf-8.

                curl -i http://127.0.0.1:3000/a-page-that-does-not-exist
            

Adjust the address to your listener. In a native application with the configuration above, an unresolved request selects 404.html and returns status 404. A request already completed by an earlier handler remains that handler's responsibility.


How a Page Is Selected

After passing control onwards, the handler inspects res.statusCode. A value of 400 or greater selects the corresponding numbered HTML page; otherwise it selects 404.html for the unresolved request. Ordinary fallback rendering is performed only while response headers remain unsent.

If the selected file does not exist, the handler changes the status to 500 and tries 500.html. If that file is also missing or cannot be read, it sends server crash - 500. For example, a request marked 403 needs 403.html to retain that status through this fallback path. The pack is not a general exception catcher: the application must set or propagate its error state.


Bypass Rules and Favicon Handling

notKindness matches the pathname without query parameters through ppm. A segment rule such as download matches that path segment, including /download/report.zip. Use explicit path patterns when a broader segment match would skip unrelated routes. Without ppm, these pattern-based bypass rules are not evaluated.

Bypass does not create a response or a substitute API error body. The relevant handler must finish the request. nofavicon suppresses /favicon.ico with status 204 when that path reaches httpKindness; a favicon already served by earlier static middleware does not reach this fallback.


Optional Redirect Mode

Setting config.serveropt.forceKRedirect=true redirects a selected existing page to /kindness/STATUS.html using the configured kindness folder name. That response has status 302 rather than the original error status. Ensure static delivery or a dedicated route serves the target directly, so requesting the error-page URL does not return to the same redirect path. Serving the HTML in place keeps the original request URL and selected error status.


Published Status

The assets report kindness, nofavicon, urlrewrite, and the adapter kind when active. They describe the mounted configuration; enabling the handler does not establish that every numbered HTML page exists. The supplied manifest declares no consumer permits. Detach logically bypasses the handler and publishes kindness=false, leaving response completion to the remaining application chain.


Documentation

This page is the HTML adaptation of the pack's README.md, with practical clarifications checked against the implementation. Complete Staxis onboarding to request GitLab access to the official sources.