adapter-node

Node.js adapter for Catmint. Produces a standalone Node.js server from the Catmint build output that can be started with node dist/server/index.js.

Import

import node from "@catmint/adapter-node";

Signature

function nodeAdapter(options?: NodeAdapterOptions): CatmintAdapter;

The default export is the nodeAdapter factory function.

Parameters

ParameterTypeRequiredDescription
optionsNodeAdapterOptionsNoConfiguration for the Node.js server.

NodeAdapterOptions

PropertyTypeDefaultDescription
portnumber3000Port to listen on.
hoststring'0.0.0.0'Host to bind to.
maxBodySizenumber1048576Maximum request body size in bytes (default 1 MB). Requests exceeding this limit receive a 413 Payload Too Large response.

Return Value

Returns a CatmintAdapter object with name: '@catmint/adapter-node'. When the adapt() method is called during build, it:

  1. Generates a standalone server entry point at dist/server/index.js
  2. Bundles the routing, middleware, and server function handlers
  3. If the build manifest has hasMiddleware: true, the generated server runs all requests (except client assets and middleware-free static routes) through the middleware pipeline before routing

Examples

// catmint.config.ts
import { defineConfig } from "catmint/config";
import node from "@catmint/adapter-node";

export default defineConfig({
  adapter: node(),
});
// With custom port and host
import { defineConfig } from "catmint/config";
import node from "@catmint/adapter-node";

export default defineConfig({
  adapter: node({
    port: 8080,
    host: "localhost",
  }),
});

After building, start the server:

node dist/server/index.js

See Also