Express Cloud Foundry Actuator Middleware

raw JSON →
1.8.0 verified Fri May 01 auth: no javascript maintenance

Express middleware providing health and info endpoints for Cloud Foundry Apps Manager, inspired by Spring Boot Actuator. Current stable version is 1.8.0 (released May 2021), with maintenance-level updates addressing dependency vulnerabilities. Key differentiators: integrates natively with Cloud Foundry's Apps Manager UI, restricts endpoints to authenticated/authorized users, and works with the companion CLI to generate build info files. Compatible with Node 6+ (legacy engine requirement). Provides only health and info endpoints (no metrics, environment, or other Spring Boot actuator endpoints). Last release was over 3 years ago; no active development expected.

error TypeError: actuator is not a function
cause actuator is imported as a default export but the package uses module.exports with a factory function.
fix
Use const actuator = require('express-cloudfoundry-actuator-middleware'); then call app.use(actuator());
error Cannot find module 'express-cloudfoundry-actuator-middleware'
cause The package was not installed, or installed in the wrong directory.
fix
Run npm install express-cloudfoundry-actuator-middleware --save in your project root.
error Route.get() requires a callback function but got a [object Object]
cause actuator() returns an object with router functions, but it's not a direct middleware; calling actuator() without using it in app.use() leads to this error.
fix
Ensure you use app.use(actuator()) and not app.get('/', actuator()).
gotcha The actuator middleware must be used before other routes to ensure endpoints are accessible.
fix Place app.use(actuator()) before route definitions.
gotcha Options object is required; passing no arguments or undefined will still enable default endpoints, but any additional configuration must be passed explicitly.
fix Use actuator({ health: true, info: true }) to explicitly enable endpoints.
gotcha The 'info' endpoint requires a build info file generated by Cloud Foundry Actuator CLI; without it, the endpoint may return empty or error.
fix Run the CLI tool before deployment: npx cloudfoundry-actuator-cli build-info
deprecated Node engine requirement is >=6, which is end-of-life. The package may not work on modern Node versions (>=18) without compat flags.
fix Use Node 16 or lower, or consider using the '--openssl-legacy-provider' flag if needed.
npm install express-cloudfoundry-actuator-middleware
yarn add express-cloudfoundry-actuator-middleware
pnpm add express-cloudfoundry-actuator-middleware

Sets up an Express app with the actuator middleware, enabling health and info endpoints for Cloud Foundry.

const express = require('express');
const app = express();
const actuator = require('express-cloudfoundry-actuator-middleware');

// Optional: configure endpoints
const options = {
  health: true,
  info: true
};

app.use(actuator(options));

app.get('/', (req, res) => res.send('Hello World!'));

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`App listening on port ${PORT}`));