Skip to content

Node Handler API (resuxjs/node) ​

resuxjs/node is the focused production Node HTTP entry point. It exports the production request handler factory and its options without requiring callers to import the CLI module directly.

Server-only

This API uses Node IncomingMessage / ServerResponse behavior and production build artifacts. It is not browser code and is not an edge-runtime-neutral Fetch handler.

Imports ​

ts
import {
  createResuxNodeHandler,
  type ResuxNodeHandlerOptions
} from 'resuxjs/node'

ResuxNodeHandlerOptions ​

ts
interface ResuxNodeHandlerOptions {
  appRoot?: string
  outDir?: string
  securityHeaders?: boolean
}
OptionDefaultDescription
appRootprocess.cwd()Application root used by the production request pipeline.
outDir<appRoot>/.resuxCompiled Resux output directory.
securityHeaderstrueEnables the production handler's built-in security-header behavior.

Paths are resolved to absolute paths when the handler is created.

createResuxNodeHandler() ​

ts
function createResuxNodeHandler(
  options?: ResuxNodeHandlerOptions
): (request: IncomingMessage, response: ServerResponse) => void

Example with Node's HTTP server:

ts
import { createServer } from 'node:http'
import { createResuxNodeHandler } from 'resuxjs/node'

const handler = createResuxNodeHandler({
  appRoot: process.cwd(),
  securityHeaders: true
})

createServer(handler).listen(3000)

The returned handler dispatches each request through Resux's production request pipeline using the resolved app/output paths and non-development build settings.

Production guard ​

Creating the handler calls the framework's production Halal Core report guard for the selected output directory before requests are served. In a normal non-test production environment, an invalid or missing authenticated report prevents startup according to the guard behavior.

See Halal Core for report signing/verification requirements.

Build requirement ​

createResuxNodeHandler() expects compiled application output; it does not run buildProject() for you.

Typical flow:

sh
resux build
node server.mjs

Use the normal Resux start/deployment commands when you do not need to embed the request handler in a custom Node server.

Security headers ​

securityHeaders defaults to true. Disable it only when another trusted layer owns the complete response-header policy and you have verified there is no coverage gap:

ts
const handler = createResuxNodeHandler({
  securityHeaders: false
})

Do not disable the setting merely to work around a CSP/header bug; fix the deployment/header composition instead.

Runtime and resumability ​

This API owns the server request boundary. It serves the server-rendered HTML/payload/runtime artifacts generated by the Resux build, but importing resuxjs/node does not change the client resumability model or make application components Vue-hydrated.

Source-aligned documentation for the Resux resumable web framework.