Registry / web-framework / on-http

on-http

JSON →
library1.0.2jsnpmunverified

on-http serves as the primary HTTP server component for the RackHD infrastructure management system, providing the web user interface and RESTful API endpoints essential for managing bare-metal hardware. Currently at its stable version 2.60.7, the project exhibits a consistent release cadence with frequent patch updates, indicating active development and maintenance. It is deployed as a standalone application, mandating the presence and correct configuration of external MongoDB and RabbitMQ instances for its operation. Its key differentiators lie in its deep integration with RackHD's capabilities for automated hardware provisioning, discovery, and orchestration, offering a structured API that defaults to version 2.0, with version 1.1 explicitly deprecated. The package also includes built-in tools for generating API documentation, task documentation, and client libraries for various programming languages, facilitating ecosystem integration.

npm install on-http
INSTALL
IMPORT
SIG · ON-HTTP
O
on-http
web-frameworkjavascriptv1.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

app
const { app } = require('on-http/lib/app');
import { app } from 'on-http/lib/app'; const app = require('on-http');
Imports the Express application instance. This package primarily uses CommonJS modules. Direct import from 'on-http' will not expose named symbols; subpath imports are needed for internal modules.
server
const { server } = require('on-http/lib/app');
import { server } from 'on-http/lib/app'; const { Server } = require('on-http');
Imports the Node.js HTTP server instance. This package primarily uses CommonJS modules. Direct import from 'on-http' will not expose named symbols; subpath imports are needed for internal modules.
nconf
const nconf = require('on-http/lib/config');
import nconf from 'on-http/lib/config';
Imports the configured nconf instance for programmatic access to runtime settings. This is an advanced use case for deep integration or testing within the CommonJS module system.

This script demonstrates how to install `on-http`, generate its documentation, start the server in the background, perform basic `curl` requests to its UI and API endpoints, and then gracefully shut it down. It highlights the prerequisite external services (MongoDB, RabbitMQ) and the common practice of using `sudo` to run the server.

#!/bin/bash # NOTE: This quickstart assumes MongoDB and RabbitMQ are already running and accessible # on their default ports (localhost:27017 for Mongo, localhost:5672 for RabbitMQ). # Clean existing node_modules and install dependencies rm -rf node_modules npm install # Generate API and task documentation (optional, but good for setup and local access) npm run apidoc npm run taskdoc # Start the on-http server in the background. # The README shows 'sudo node index.js', which is typically required for system ports or permissions. # For development, you might adjust permissions or run on a higher port. sudo node index.js & SERVER_PID=$! echo "on-http server started (PID: $SERVER_PID). Waiting for it to become ready..." sleep 10 # Give the server some time to initialize and connect to dependencies # Perform basic health checks and access documentation echo "Accessing RackHD UI and API endpoints:" # Check the Web UI curl -s -o /dev/null -w "HTTP Status: %{http_code}\n" http://127.0.0.1/ui echo "- UI expected at http://127.0.0.1/ui" # Check the API documentation curl -s -o /dev/null -w "HTTP Status: %{http_code}\n" http://127.0.0.1/docs echo "- API Docs expected at http://127.0.0.1/docs" # Example: Try to fetch a list of nodes (requires RackHD to have discovered nodes) curl -s -o /dev/null -w "HTTP Status: %{http_code}\n" http://127.0.0.1/api/current/nodes echo "- API endpoint /api/current/nodes (status 200 means success, data depends on setup)" # Clean up: Kill the background server process kill $SERVER_PID wait $SERVER_PID 2>/dev/null echo "on-http server (PID: $SERVER_PID) stopped."
Debug
Known issues
gotchaThe `on-http` server requires external MongoDB and RabbitMQ instances to be running and accessible for correct operation. Failure to connect to these services will prevent the server from starting or functioning properly.
fix
Ensure MongoDB and RabbitMQ services are installed, started, and configured to be reachable from the `on-http` server. Check logs for connection errors during startup.
affects: >=2.0.0
deprecatedThe 1.1 API for RackHD is officially deprecated. While it may still function, new development and integrations should exclusively target the 2.0 API.
fix
Update all API calls to utilize the 2.0 API, typically by prefixing endpoints with `/api/2.0/` or `/api/current/`. Refer to RackHD's readthedocs for functional differences and migration guides.
affects: >=2.0.0
gotchaThe official documentation often shows running `node index.js` with `sudo`. Running Node.js applications as root is generally a security risk and can lead to permission issues with files created by the application. Consider alternative deployment strategies.
fix
Prefer running the application under a dedicated, unprivileged user account. If port 80/443 access is required, use a reverse proxy (e.g., Nginx, Apache) or grant specific port permissions (e.g., using `authbind` or `setcap`).
affects: >=2.0.0
gotchaWhen debugging Node.js applications, the `node-debug` command is noted to not work well with `on-http`. Instead, `node-inspector` is recommended for GUI-based debugging.
fix
Install `node-inspector` globally (`npm install node-inspector -g`), start it in the background (`node-inspector --preload=false &`), and then launch `on-http` with debugging enabled (`sudo DEBUG=express:* node --debug-brk index.js`).
affects: >=2.0.0
Errors
Common errors & fixes
Error: failed to connect to [localhost:27017]
The MongoDB database server is not running or is inaccessible from the on-http server.
fix
Verify that MongoDB is running and listening on the expected port (default 27017). Check network connectivity and MongoDB configuration settings.
Failed to connect to RabbitMQ broker: amqp://localhost
The RabbitMQ message broker is not running or is inaccessible from the on-http server.
fix
Ensure the RabbitMQ service is active and listening on its configured port (default 5672). Review RabbitMQ logs for startup issues.
TypeError: Cannot read property 'defaultBackend' of undefined
The `fileService` configuration key, or its sub-keys like `defaultBackend`, are missing or incorrectly defined in the application's configuration files.
fix
Inspect the configuration files (e.g., `./config/default.json` or environment variables) to ensure the `fileService` object exists and contains a `defaultBackend` key with a valid backend string, as well as configurations for all defined backends.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
mongodbrequiredRequired as the primary data store for RackHD operations.
rabbitmqrequiredRequired for inter-service communication and task queuing within RackHD.
Agent activity
6 hits · last 30 days
node
6
Resources