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.

htmlExpress

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


Description

htmlExpress renders server-side HTML from JavaScript page modules through html-express-js. The pack's manifest.label is htmlexpress and its manifest.typology is viewengine. It registers on serverApp and uses the native Node.js application as the standard path; the pack name does not require you to select the Express framework.

Templates and companion modules stay in server-templates. Browser scripts, styles, and images stay in server-public. The renderer executes a page's exported view function for the request and sends its HTML directly; it does not build HTML files into the public directory.


Read before flight

  • We suggest treating page modules and companions as trusted server-side code. Keep them outside public static roots, and register authorization before the renderer for private pages. A backoffice folder name does not restrict access.

  • We suggest escaping untrusted values before interpolating them into HTML. The render template tag concatenates values without automatic HTML escaping. Review page output and error responses before deployment, rather than relying only on status codes.

  • We suggest keeping privileged equipment injection disabled unless required. Start reusable fragments as common companion functions, as in the examples below, and validate optional filesystem includes on your deployment host before relying on them.


Requirements and Installation

The manifest declares serverApp, ppm, httpStatics, and httpListener. The renderer directly obtains serverApp and uses the ppm library for path exclusions. httpStatics serves browser resources; httpListener provides the application's listener. The npm dependency is html-express-js. The pack expects the factory API with an engine method; older 1.x releases use a different API. These examples were checked with version 7.0.0, which declares Node.js 20.19 or newer. Install through the Manager:

                manager -> install -> htmlexpress
            

If the installation profile has not installed its npm dependency, run this in the project directory:

                npm install html-express-js
            

Keep serverApp and ppm available before the renderer and apply request checks and authorization before page handling. Select one provider for the viewengine runtime slot, so use htmlExpress as an alternative to EJS. Prepare KEY:VIEWENGINE, the project Vault keys, and integrity records. The supplied serverApp manifest already permits htmlexpress. Normal page rendering is automatic and requires no consumer Vault request to this pack; its manifest declares permits=false.


Files Map

File Purpose
system-lrpcks/htmlexpress/main.js Attaches the renderer, resolves page modules, loads companions, and sends HTML
system-lrpcks/htmlexpress/configs.js Supplies Guardian rules, the template root, and rendering defaults
system-lrpcks/htmlexpress/manifest.json Declares label htmlexpress, typology viewengine, and required packs
server-templates/frontoffice/index.js Supplied main page module
server-templates/frontoffice/test.js Supplied second page module
server-templates/frontoffice/~common.js Shared server-side helpers and navigation
server-templates/frontoffice/~index.js Companion exports for index.js
server-templates/backoffice/index.js Supplied backoffice example, separate from frontoffice
server-public/resources/ Supplied styles.css, hellodev.webp, and testscript.js browser assets
README.md Original pack reference and usage examples

Configuration

In config.js, folder names belong to config.serveropt.folders, view settings to config.serveropt.templating, and Guardian rules to config.engineopt.guard. Merge these branches into the exported config object, preserving other pack rules. The example explicitly sets the shared frontoffice name, normally supplied by httpStatics. It also adds exclusions for ~ companion paths and the includes directory; those two rules are additional to the supplied default exclusions.

                // config.js -> config (merge into the exported object)
                engineopt: {
                    guard: {
                        allowBareDeps: true,
                        allowedDeps: [{
                            pack: 'htmlexpress',
                            roots: ['htmlexpress'],
                            require: ['html-express-js']
                        }],
                        allowedImports: [{
                            pack: 'htmlexpress',
                            files: ['./server-templates/*', './system-lrpcks/htmlexpress/*']
                        }],
                        allowedFileAccess: [{
                            pack: 'htmlexpress',
                            roots: ['./server-templates', './server-templates/*']
                        }]
                    }
                },
                serveropt: {
                    folders: {
                        templates: 'server-templates',
                        frontoffice: 'frontoffice'
                    },
                    templating: {
                        enabled: true,
                        allowAssets: true,
                        common: 'frontoffice/~common',
                        includes: 'includes',
                        noApiRoots: true,
                        exclude: ['.*', '.*/*', '*download*', '*healthz*', '*readyz*', '~*', 'includes'],
                        allowAssetsLayers: false,
                        allowAssetsEquipments: false,
                        equipConfig: 'template',
                        equiplogs: true,
                        equipLibraries: false,
                        equipLayers: false,
                        equipEngine: false,
                        callLayers: [],
                        dangerInjectionLog: false
                    }
                }
            

allowBareDeps is global; the dependency names are still declared through allowedDeps. The layer imports common and page companions through the Core's importing gate. Page rendering and filesystem fragment loading are performed by html-express-js itself, so do not treat every internal package import as a separate Guardian-gated operation. Review the template code and installed dependency together. Update permission paths if you move their roots.


Keep Templates Separate from Public Assets

                project-root/
                β”œβ”€β”€ system-lrpcks/
                β”‚   └── htmlexpress/
                β”œβ”€β”€ server-templates/
                β”‚   β”œβ”€β”€ frontoffice/
                β”‚   β”‚   β”œβ”€β”€ index.js
                β”‚   β”‚   β”œβ”€β”€ test.js
                β”‚   β”‚   β”œβ”€β”€ ~common.js
                β”‚   β”‚   └── ~index.js
                β”‚   β”œβ”€β”€ backoffice/
                β”‚   β”‚   └── index.js
                β”‚   └── includes/              # optional filesystem fragments
                └── server-public/
                    └── resources/
                        β”œβ”€β”€ styles.css
                        β”œβ”€β”€ testscript.js
                        └── hellodev.webp
            

frontoffice and backoffice are sibling directories under server-templates. The shared folders.frontoffice name is resolved beneath folders.templates for rendering and beneath folders.public by httpStatics for static delivery. These are separate roots. JavaScript in server-templates executes on the server; a browser script belongs in server-public and is referenced through an HTML script tag. Templates and companions are outside this pack's own HMAC snapshot, so include them in your application release review.


Create a JavaScript Page

Save the following as server-templates/frontoffice/index.js. Export the named view function; it receives the Staxis data object and the render template tag inside its first argument.

                export const view = ({ data, render }) => render`
                    <!doctype html>
                    <html lang="en">
                        <head>
                            <meta charset="UTF-8">
                            <title>htmlExpress on Staxis</title>
                            <link rel="stylesheet" href="/resources/styles.css">
                        </head>
                        <body>
                            <h1>htmlExpress is running</h1>
                            ${data.assets?.common?.layout?.menu?.(data, render) || ''}
                            <p>${data.assets?.page?.hello?.() || ''}</p>
                            <script src="/resources/testscript.js"></script>
                        </body>
                    </html>
                `
            

Use the same export shape for test.js and other pages. The renderer supplies render, so these basic modules need no import from html-express-js. The stylesheet and browser script URLs require httpStatics with the matching public root.

                export const view = ({ data, render }) => render`
                    <h1>Second page</h1>
                    ${data.assets?.common?.layout?.menu?.(data, render) || ''}
                `
            

Add Common and Page Companions

With config.serveropt.templating.allowAssets=true, common names the shared module relative to server-templates, without .js. Create server-templates/frontoffice/~common.js:

                export default {
                    layout: {
                        menu: (data, render) => render`
                            <nav>
                                <a href="/index">Home page</a> |
                                <a href="/test">Second page</a>
                            </nav>
                        `
                    }
                }
            

Create server-templates/frontoffice/~index.js for the index.js page:

                export default {
                    hello: () => 'htmlExpress page companion loaded'
                }
            

The page accesses these values through data.assets.common and data.assets.page. A page named test.js can have a matching ~test.js beside it. These are server-side exports, not files downloaded by the browser. The common module and companion file list are loaded during attach; matching page companions are imported on demand. Module caching applies, so keep request-specific mutable state out of module-level variables and restart after layout changes.

To render without companions, disable allowAssets in its full parent branch. The page examples above use optional access and continue to work without data.assets:

                // config.js -> config (merge into the exported object)
                serveropt: {
                    templating: {
                        allowAssets: false
                    }
                }
            

Optional Filesystem Fragments

config.serveropt.templating.includes names the html-express-js fragment directory beneath server-templates. It defaults to includes. It is separate from the shared ~common.js companion. The dependency's view API makes rendered filesystem fragments available through the second view argument's includes object. Keep that directory empty when using only the common-helper approach shown above, and validate filesystem fragment loading on your host before adding those modules.

The pack README describes this optional directory; the dependency's own documentation describes its fragment API. Moving fragment files into server-public would expose server-side source as static files and is not part of this rendering flow.


URLs and Request Data

Requested Path Result with the Supplied Layout
/ or /index server-templates/frontoffice/index.js
/test server-templates/frontoffice/test.js; ~test.js is its optional companion
/backoffice/index server-templates/backoffice/index.js
/test.js or /resources/styles.css Extension-bearing requests pass to later middleware
A missing page Passes to the next handler

The resolver strips queries, collapses repeated slashes, removes a trailing slash, and uses /index for /. It tries the frontoffice root first, then the overall template root. It does not reserve the backoffice prefix or automatically select nested index.js files. Keep the sibling directory layout above. The handler has no HTTP method filter of its own.

data Property Value
url Cleaned path, with / represented as /index
hostname Host request header, falling back to req.hostname
protocol X-Forwarded-Proto request header, or http
pagename Final segment of the cleaned path
useragent User-Agent request header, or an empty string
assets Common and page exports, plus explicitly enabled context, when allowAssets is true

These request headers are not authenticated identity or trusted-origin information. The render tag does not escape interpolated values: keep reusable HTML under application control and escape untrusted text before including it.

                curl -i http://127.0.0.1:3000/
                curl -i http://127.0.0.1:3000/test
                curl -i http://127.0.0.1:3000/backoffice/index
            

Exclusions and Optional Runtime Context

All settings here belong to config.serveropt.templating. exclude accepts ppm rules as an array or one string. true instead collects config.serveropt.publicDeny and config.database.exclude when they are arrays. Matching requests are marked 404 and continue to later handlers. noApiRoots=true adds roots from config.database.dbapis, config.database.apiroot, and config.serveropt.apiroot. A string or array supplies explicit API roots; false omits that step.

allowAssetsEquipments controls whether selected equipment is copied under data.assets. equipConfig selects true for full config, serveropt for server options, template for templating options, or minimal for a cloned serveropt.templating branch. equiplogs, equipLibraries, and equipEngine select the corresponding context entries. Keep them limited to what the templates need.

allowAssetsLayers controls data.assets.layers. callLayers currently uses each configured name as both the provider's pack label and runtime slot, and expects the target to expose using. Keep it empty unless that integration is required. The final layers entry also replaces the layers equipment selected by equipLayers. dangerInjectionLog=true suppresses the companion warning; it does not disable companion execution or change permissions.


Responses, Compression, and Published Status

Rendered responses use text/html; charset=utf-8 and Cache-Control: no-store. The current handler assigns status 200 after its rendering attempt, including when it has caught a rendering error and generated a diagnostic body. Check the rendered content and production error handling as well as the HTTP status. Outer handler failures are logged and can pass to later middleware.

httpCompression is optional. In native mode, an available compressor() is registered before the renderer. Keep one compression owner and validate transformed HTML as described in httpCompression. The published assets report status, engine='htmlExpress', and routing=['js']; they do not expose a separate rendering API for other packs.

For the original pack layout and examples, see the pack README.


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.