serve

    Minimal static HTTP file server for MoonX.

    command-line
    moonx
    wasm
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    14 days ago
    Downloads
    104

    #serve

    Serve static files over HTTP for MoonX.

    moonx cli/serve@0.1.0 [--host ADDRESS] [-p PORT|--port PORT] [DIRECTORY]

    #Supported scope

    Serve regular files with GET and HEAD, including hidden files and symlinks whose targets remain inside the root. The directory defaults to ., the address to 127.0.0.1, and the port to 8000. Print the actual listen address to stderr.

    Directories serve index.html and redirect to a trailing slash when needed. Responses include Content-Length and an extension-based MIME type; unknown extensions use application/octet-stream, with MIME sniffing disabled. Queries do not select files. Invalid paths return 400, missing or inaccessible files return 404, and unsupported methods return 405.

    #Options

    OptionDescription
    --host ADDRESSSet a numeric IPv4 or IPv6 listen address.
    -p PORT, --port PORTSet a port from 0 through 65535; 0 selects an available port. Accepts --port=8000 and -p8000.
    --End option parsing before the directory operand.
    -h, --help / -V, --versionShow help / package version without reading stdin or starting a listener.

    Each option may appear once. Argument syntax errors print a diagnostic with usage to stderr and exit 1.

    #Limitations

    • cli/serve@0.1.0 is not published yet; the MoonX commands require that release.
    • Directory listing, SPA fallback, uploads, ranges, caching, compression and TLS are unsupported.
    • Paths are percent-decoded once as UTF-8. Traversal segments, malformed escapes, control bytes, backslashes, drive/stream colons and Windows device/alias names are rejected on every platform. Outside-root and nonregular targets return 404.
    • At most 64 connections are served at once. Files must remain stable: shortening a file aborts its response, and appended bytes are excluded.
    • Wasm policy is supplied by the launcher and must allow reads under the root and binding the listen address. Path checks and policy do not provide race-free confinement against hostile filesystem replacement; use a trusted directory.

    #Examples

    moonx cli/serve@0.1.0 public moonx cli/serve@0.1.0 --host 127.0.0.1 -p8080 public

    Source Files