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

Packages

@xtaskjs/fastify-http

Fastify adapter for the same controller model used by core and Express.

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

Overview

What this package owns in the runtime

Fastify support mirrors Express support but keeps Fastify-specific serving, view rendering, and static file behavior behind the same framework contracts.

What it provides

  • Wraps a Fastify instance and exposes the shared xtask HTTP adapter contract.
  • Supports static assets and file-template rendering.
  • Preserves controller portability between Express and Fastify.
  • Backs both pure Fastify and Fastify + TypeORM samples.

How it fits

  • Selected explicitly with new FastifyAdapter(fastifyApp).
  • Good fit when you want Fastify performance but keep xtask decorators and DI.

Usage Chart

How strongly this package shapes the runtime

Bootstrap

3/5

HTTP Delivery

5/5

Rendering

4/5

Integrations

4/5

Performance

5/5

Package Flow

How this package moves through xtaskjs runtime phases

Before startup

Create a Fastify instance with your preferred logger and plugins before wiring it into the framework adapter.

During CreateApplication()

The Fastify adapter translates the shared xtaskjs controller contract into Fastify routes, static assets, and template lookups.

During app.close()

Shutdown flows through the application close sequence so Fastify resources stop together with the rest of the xtask lifecycle.

API Surface

Representative exports from the upstream package

Adapter runtime

  • FastifyAdapter
  • view
  • HttpAdapter
  • HttpRequestHandler

Request and response types

  • HttpRequestLike
  • HttpResponseLike
  • HttpServerOptions
  • HttpViewResult
  • HttpAdapterType

Adapter options

  • FastifyAdapterOptions
  • FastifyTemplateEngineOptions
  • FastifyStaticFilesOptions

Usage

Typical adoption flow

1. Create the Fastify app

Start from a Fastify instance when you want lower-level performance tuning or plugin-driven composition.

2. Wrap it with the adapter

Pass new FastifyAdapter(fastifyApp) into CreateApplication() to keep the same controller surface used by node-http and Express.

3. Add persistence or views

Pair the adapter with TypeORM or file-backed views without rewriting route handlers or service classes.

Example

Reference snippet

Fastify bootstrap
import fastify from "fastify";
import { CreateApplication } from "@xtaskjs/core";
import { FastifyAdapter } from "@xtaskjs/fastify-http";

const fastifyApp = fastify({ logger: true });

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

Samples

Official samples to inspect next

Reference samples: 03-fastify_app and 04-typeorm_app

Related

Packages commonly used with this one