Skip to content

@genga-cms/node

Genga in a Node server: one listener for node:http and one middleware for Express. It serves the admin app, its API, the media files, the public API and MCP, and gives every other path to your server.

Package Node Express
@genga-cms/node >=22.12 ^5

The version of @genga-cms/node is the version of genga.

// node:http
import http from 'node:http';
import { toNodeListener } from '@genga-cms/node';
http.createServer(toNodeListener(genga, { fallback: (req, res) => res.writeHead(404).end() })).listen(3000);
// Express 5
const app = express();
app.use(toNodeListener(genga)); // before express.json()
app.use(express.json());
app.get('/blog/:slug', async (req, res) => {
const doc = await genga.getDocument('posts', req.params.slug);
if (!doc) return res.sendStatus(404);
res.send(render(doc));
});
  • WARNING: mount it before any body parser. It reads the body of a Genga request as a stream. It does not read the body of another request, so express.json() after it still works.
  • It streams the response: a large media file or a stream of events is not buffered.
  • It gives the socket address to Genga, which counts it as one more proxy hop. Set trustedProxies to the number of proxies in front of the Node server.
  • Without fallback, it calls next() under Express, and answers 404 under node:http.
  • Hono needs no helper: app.all('*', async (c, next) => (await genga.handle(c.req.raw)) ?? next()).

The Genga server image (ghcr.io/sakuga-software/genga) runs on this listener.