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.

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

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