{"library":"on-http","title":"RackHD HTTP Server (on-http)","description":"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.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install on-http"],"cli":null},"imports":["const { app } = require('on-http/lib/app');","const { server } = require('on-http/lib/app');","const nconf = require('on-http/lib/config');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"#!/bin/bash\n\n# NOTE: This quickstart assumes MongoDB and RabbitMQ are already running and accessible\n# on their default ports (localhost:27017 for Mongo, localhost:5672 for RabbitMQ).\n\n# Clean existing node_modules and install dependencies\nrm -rf node_modules\nnpm install\n\n# Generate API and task documentation (optional, but good for setup and local access)\nnpm run apidoc\nnpm run taskdoc\n\n# Start the on-http server in the background.\n# The README shows 'sudo node index.js', which is typically required for system ports or permissions.\n# For development, you might adjust permissions or run on a higher port.\nsudo node index.js &\nSERVER_PID=$!\n\necho \"on-http server started (PID: $SERVER_PID). Waiting for it to become ready...\"\nsleep 10 # Give the server some time to initialize and connect to dependencies\n\n# Perform basic health checks and access documentation\necho \"Accessing RackHD UI and API endpoints:\"\n\n# Check the Web UI\ncurl -s -o /dev/null -w \"HTTP Status: %{http_code}\\n\" http://127.0.0.1/ui\necho \"- UI expected at http://127.0.0.1/ui\"\n\n# Check the API documentation\ncurl -s -o /dev/null -w \"HTTP Status: %{http_code}\\n\" http://127.0.0.1/docs\necho \"- API Docs expected at http://127.0.0.1/docs\"\n\n# Example: Try to fetch a list of nodes (requires RackHD to have discovered nodes)\ncurl -s -o /dev/null -w \"HTTP Status: %{http_code}\\n\" http://127.0.0.1/api/current/nodes\necho \"- API endpoint /api/current/nodes (status 200 means success, data depends on setup)\"\n\n# Clean up: Kill the background server process\nkill $SERVER_PID\nwait $SERVER_PID 2>/dev/null\necho \"on-http server (PID: $SERVER_PID) stopped.\"","lang":"bash","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}