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.

HTTP Series

The HTTP series is the family of packs that prepares an HTTP application, adds request handling, and starts its listener. Each pack has a focused role, so you can compose the parts your application needs. HTTP series is a documentation grouping, not a pack to install or a runtime typology. Native Node.js is the standard HTTP delivery; framework adapters provide optional extension paths.


From Packs to an HTTP Application

serverApp creates the HTTP application. Other packs obtain authorized access to it and register middleware or routes. httpListener starts the prepared application listening for connections. View engines can also participate by registering their rendering routes; their alternatives are presented in the separate viewEngine family.

Pack Role in the HTTP application
serverApp Prepares the HTTP application and its middleware-registration API
httpShield Adds configured request checks and response-header policy
httpPing Observes request signals and optionally returns a pong
httpCompression Provides optimization helpers and runtime-specific compression integration
httpStatics Serves files from the configured public roots
httpDownloads Delivers temporary exports through an HTTP download alias
httpRestParser Provides request-decoding and response helpers for HTTP consumers
httpKindness Provides fallback handling for requests left to the end of the chain
httpListener Starts the real listener and manages its connection lifecycle

The menu groups these packs by responsibility. A pack can belong to the HTTP family whether its current technical form is a library or a runtime layer. Select the necessary components and follow their dependencies and registration requirements; the family is not a mandatory all-or-nothing stack.


Three Orders to Keep Visible

  • Pack preparation

    config.stack lists pack labels in the order Staxis prepares them. Providers must be available before their consumers. A pack can register several HTTP handlers, publish helpers without registering a handler, or start a listener.

  • Middleware registration

    Calls such as serverApp.using(label, handler) build the HTTP middleware chain. The label identifies that handler for diagnostics; it is separate from a pack's manifest.label and manifest.typology. One pack may contribute multiple named handlers.

  • Request execution

    A request enters through the listener and reaches the prepared handlers. In the native chain, next() passes it onwards; completing the response ends that path. A rejected request, a static-file request, and a rendering request can therefore execute different portions of the same registered chain.

The pack stack creates a process; it is not itself a record of that process's execution. httpListener is typically prepared after the handlers, while incoming connections arrive through that listener first. This distinction is why the HTTP chain has its own diagnostic trace.


Inspect the HTTP Chain

serverApp can print a MIDDLEWARE CHAIN report through Staxis logging. The report shows which instrumented middleware a request reached, in which order, and where those handlers were registered. This helps explain the application during development and makes the same behaviour visible in a practical demonstration.

In the project's config.js, enable config.serveropt.chainlog before startup. Merge the following serveropt branch into the exported config object, preserving other settings:

                // config.js -> config (merge into the exported object)
                serveropt: {
                    chainlog: true
                }
            

The report includes the request URL, response status, executed-entry count, and each recorded middleware label, timestamp, and caller location. Timestamps record when an entry was reached; they are not measurements of each middleware's execution duration. The trace covers instrumented handlers, not every internal operation of every framework or pack.


A Small Trace Demonstration

Inside an authorized consumer pack that already obtained serverApp as described in its manual page, register two named handlers:

                serverApp.using('request-observer', (req, res, next) => {
                    return next()
                })

                serverApp.using('example-route', (req, res, next) => {

                    if (req.url !== '/example') return next()

                    res.statusCode = 200
                    res.setHeader('Content-Type', 'text/plain; charset=utf-8')
                    res.end('Example response')

                })
            

These are middleware diagnostic labels, not pack labels or runtime slots. A request to /example reaches both handlers and is completed by example-route. A request to another path passes through both and continues to any later handlers or the end of the native chain.

In the current native adapter, the report is emitted when chainEnd is reached, including chain exhaustion and selected error paths. A handler that directly completes a response does not automatically invoke that report. For an initial native trace demonstration, send an unmatched request that reaches the end of the chain. Report completion coverage depends on the adapter; verify the paths you intend to demonstrate.

Start with a minimal local application, show its configured pack order, then compare the registered handler labels with the request trace. Add an early response or another handler to show how the execution path changes. The pack order, registration order, and observed request path can then be inspected together rather than inferred from the stack alone.