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.

httpDownloads

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


Description

httpDownloads delivers files from the engine's temporary directory through a configured HTTP alias. Its label and typology are both httpDownloads. It checks the requested path, file extension, and source size, then streams the file as an attachment. Optional host utilities can package a file before delivery. Use it for temporary exports and generated artifacts rather than ordinary public static assets.


Read before flight

  • We suggest placing authentication and file-level authorization before this middleware when downloads are private. Files inside the configured temporary root can be requested by their alias path; File Manager access profiles do not authorize the HTTP user.

  • We suggest keeping the temporary area and any symbolic links under trusted control. Select the extensions and source-size limit for your exports, and use simple generated filenames. We suggest keeping archive packaging enabled for ordinary export downloads, and selecting direct delivery only when the consumer needs the original format. Packaging does not validate file contents.

  • We suggest budgeting temporary disk space and simultaneous archive jobs for your traffic. chunkSize is a stream buffer size, not a bandwidth or concurrency limit. Keep source-file retention and cleanup in the application that produces the exports.


Requirements and Installation

The required pack is serverApp, whose supplied manifest already permits httpDownloads's label. No extra npm dependency is required. Install through the Manager:

                manager -> install -> httpDownloads
            

Place httpDownloads after serverApp and any request checks or authorization middleware that should apply to downloads, before httpListener. Prepare the project keys and integrity records. The layer mounts its HTTP handler automatically; other packs normally use the URL convention rather than requesting a download API through the Vault.

The supplied configuration enables config.engineopt.guard.allowOpaqueExecution for host-tool detection and archive commands. This is a global Guardian setting; review it together with your deployment policy. Optional packaging needs the host utilities described below.


Files Map

File Purpose
manifest.json Declares the pack identity and serverApp requirement
configs.js Provides the temporary root, Guardian rules, alias, and download limits
main.js Mounts download handling, probes archive tools, and streams files
README.md Pack reference and alias example

Configuration

In the project's config.js, the source root belongs to config.engineopt.folders.temp, file-access policy to config.engineopt.guard, and HTTP settings to config.serveropt.downloads. Merge these branches into the exported config object, preserving other folders and Guardian rules. This example keeps the supplied safeZipping=true default for archive delivery.

                // config.js -> config (merge into the exported object)
                engineopt: {
                    guard: {
                        allowOpaqueExecution: true,
                        allowedFileAccess: [
                            {
                                pack: 'httpDownloads', // Pack label used by Guardian
                                roots: ['./system-temp', './system-temp/*']
                            }
                        ]
                    },
                    folders: {
                        temp: 'system-temp'
                    }
                },
                serveropt: {
                    downloads: {
                        enable: true,
                        alias: 'download',
                        maxFileSize: 512 * 1024 * 1024,
                        chunkSize: 64 * 1024,
                        safeZipping: true,
                        exclude: [
                            'exe', 'bat', 'cmd', 'com', 'msi', 'ps1',
                            'sh', 'bash', 'run', 'js', 'mjs', 'cjs'
                        ]
                    }
                }
            
Option under config.serveropt.downloads Behaviour
enableControls the handler's download-enabled branch
aliasURL prefix; use a simple segment such as download without surrounding slashes
maxFileSizeMaximum source-file size in bytes; supplied as 512 MiB
chunkSizeRead-stream highWaterMark in bytes; supplied as 64 KiB
safeZippingPackages files before delivery when true, except recognized existing archives
excludeDenied final extensions, case-insensitive and written without dots

Keep numeric limits positive. Missing or zero maxFileSize falls back to 50 MiB in the implementation, rather than the 512 MiB supplied by configs.js; missing or zero chunkSize falls back to 64 KiB. Changing the temporary directory also requires a matching Guardian file-access scope.


Example: Download a Generated Export

With the configuration above, create an export at project-root/system-temp/report.json using your application or File Manager. Its relative path inside the temporary area becomes the suffix of the HTTP alias:

                project-root/system-temp/report.json
                    -> GET /download/report.json

                project-root/system-temp/exports/report.json
                    -> GET /download/exports/report.json
            
                curl -D - -OJ http://127.0.0.1:3000/download/report.json
            

Adjust the address to your listener. The URL identifies the source report.json, while the response supplies report.json.tar.gz, report.json.zip, or report.json.gz according to the detected archiver. The -OJ options save it using the attachment filename supplied by the server. The response includes Content-Disposition: attachment, Content-Length, and Cache-Control: no-store. The source file remains in place after delivery. Query parameters are not part of the file path. The handler serves GET; HEAD and other methods continue to later middleware.


Archive Delivery by Default

Keep config.serveropt.downloads.safeZipping=true for the standard packaged-download flow. Extensions .gz, .zip, .tgz, and .tar are treated as existing archives and sent directly. Other files require a detected host utility; without one, those requests return a download error rather than silently falling back to raw delivery.

HostDetection orderDelivery format
Windowstar, then zipfilename.tar.gz or filename.zip
Other platformsgzip, then zipfilename.gz or filename.zip

The gzip path additionally invokes sh. Tools must be executable by the host process. Packaging creates a temporary archive under the same temporary root, streams that artifact, and attempts to remove it after delivery. It retains the source file. maxFileSize checks the source before packaging; it is not a total disk quota or an archive-job timeout. Inspect the attachment filename when saving a packaged response, since its extension changes.


Direct Delivery for Specific Needs

Set config.serveropt.downloads.safeZipping=false in config.js when an integration specifically needs the original file, such as a client consuming an unwrapped export. Direct delivery uses application/octet-stream and Content-Disposition: attachment with the source filename. File-size and extension checks still apply. Choose this mode deliberately for that use case.


Request Results and Published Status

Requests outside the alias normally continue to later middleware. The alias alone, missing files, directories, excluded extensions, paths rejected by the root check or Guardian, and oversized files are reported through logs and return status 503 with download error when headers have not been sent. These failures currently share one HTTP response rather than separate 403, 404, or 413 statuses.

The published assets report downloads and alias. They describe layer state rather than exposing file-management operations or implementing user authorization. No consumer permits are declared by the supplied manifest. Apply reviewed configuration changes through your normal application restart.


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.