xTaskjs 1.0 is live: role-based accounts, documentation, and a customizable interface.

Packages

@xtaskjs/express-http

Express adapter with static assets and template engine integration.

npm install @xtaskjs/express-http express reflect-metadata Package path: packages/express-http

Overview

What this package owns in the runtime

The Express adapter translates framework routes into Express request handling. It adds static files, template engines, and JSON or rendered-view responses without changing controller code.

What it provides

  • Wraps an existing Express application instance.
  • Supports native Express view engines such as Handlebars.
  • Serves static assets and rendered templates from configurable folders.
  • Uses the same controller contracts as node-http and Fastify.

How it fits

  • Selected explicitly with new ExpressAdapter(expressApp).
  • Pairs naturally with view(...) return values from controllers.
  • Used by the current xtaskjs.io site and the 07-security_express_app sample.

Usage Chart

How strongly this package shapes the runtime

Bootstrap

3/5

HTTP Delivery

5/5

Rendering

5/5

Integrations

4/5

Messaging

3/5

Package Flow

How this package moves through xtaskjs runtime phases

Before startup

Create an Express app, register its middleware stack, and optionally configure template engines or static asset behavior.

During CreateApplication()

The Express adapter maps xtaskjs routes into Express handlers and preserves view(), JSON, and status-code responses.

During app.close()

The xtask application stops the active server while your existing Express middleware and configuration remain the same application-wide boundary.

API Surface

Representative exports from the upstream package

Adapter runtime

  • ExpressAdapter
  • view
  • HttpAdapter
  • HttpRequestHandler

Request and response types

  • HttpRequestLike
  • HttpResponseLike
  • HttpServerOptions
  • HttpViewResult
  • HttpAdapterType

Adapter options

  • ExpressAdapterOptions
  • ExpressTemplateEngineOptions
  • ExpressStaticFilesOptions

Usage

Typical adoption flow

1. Create the Express app

Enable JSON parsing, cookies, sessions, or any other Express middleware before handing control to xtaskjs.

2. Pass the adapter

Wrap the instance with new ExpressAdapter(expressApp) and pass it into CreateApplication().

3. Return framework-native results

Keep controllers portable by returning plain objects or view() results while the adapter handles Express-specific rendering details.

Example

Reference snippet

Express bootstrap with templates
import express from "express";
import { CreateApplication } from "@xtaskjs/core";
import { ExpressAdapter } from "@xtaskjs/express-http";

const expressApp = express();
expressApp.use(express.json());

await CreateApplication({
  adapter: new ExpressAdapter(expressApp),
  autoListen: true,
  server: { host: "127.0.0.1", port: 3000 },
});

Samples

Official samples to inspect next

Reference samples: 02-express_app and 07-security_express_app

Related

Packages commonly used with this one