{"library":"node-static-auth","title":"Node.js Static Server with Basic Auth","description":"node-static-auth provides a static file server for Node.js, integrating features like Basic authentication, access file logging with rotation, and custom error pages (401, 404, 500). It supports both HTTP and HTTPS, including an HTTP listener for automatic redirects to HTTPS, and historically offered experimental HTTP/2 support for Node.js versions 9.x and above. The package bundles popular modules like `node-static`, `basic-auth`, `morgan`, and `rotating-file-stream` to deliver its functionality. As of its last known stable release (1.0.6), it caters to older Node.js environments (engines >= 0.10.0) and has not seen active development in many years, making it unsuitable for modern applications requiring current security standards or active maintenance.","language":"javascript","status":"abandoned","last_verified":"Wed Apr 22","install":{"commands":["npm install node-static-auth"],"cli":null},"imports":["const NodeStaticAuth = require('node-static-auth');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const NodeStaticAuth = require('node-static-auth');\n\n// IMPORTANT: Replace 'path-to-public-directory' with the actual path to your static files.\n// For example, if your static files are in a 'public' folder in the project root:\n// const PUBLIC_DIR = path.join(process.cwd(), 'public');\n// Ensure 'public' directory exists and contains 'index.html', 'your-forbidden.html', etc.\n\nconst config = {\n    nodeStatic: {\n        root: 'path-to-public-directory', // e.g., 'public'\n        options: {\n            indexFile: 'your-index.html' // e.g., 'index.html'\n        },\n        customPages: {\n            forbidden: 'your-forbidden.html', // e.g., '401.html'\n            notFound: 'your-not-found.html',   // e.g., '404.html'\n            error: 'your-error.html'         // e.g., '500.html'\n        }\n    },\n    server: {\n        port: 3001,\n        http2: false, // Set to true if running Node >= 9.x, but note limitations\n        ssl: {\n            enabled: true,\n            httpListener: 3000,\n            // Example: Replace with actual paths to your SSL certificate and key\n            // key: path.join(process.cwd(), 'ssl', 'server.key'),\n            // cert: path.join(process.cwd(), 'ssl', 'server.crt'),\n            key: process.env.SSL_KEY_PATH ?? 'path/to/server.key', // Placeholder\n            cert: process.env.SSL_CERT_PATH ?? 'path/to/server.crt' // Placeholder\n        }\n    },\n    auth: {\n        enabled: true,\n        users: {\n            admin: 'password123'\n        }\n    },\n    logger: {\n        enabled: true,\n        path: 'access.log',\n        type: 'combined', // Standard Apache combined log format\n        rotation: {\n            interval: '1d', // Rotate daily\n            maxFiles: 10    // Keep a maximum of 10 rotated log files\n        }\n    }\n};\n\nconst server = new NodeStaticAuth(config);\nconsole.log(`Server running on HTTPS at https://localhost:${config.server.port} and HTTP listener on http://localhost:${config.server.ssl.httpListener}`);\n","lang":"javascript","description":"This quickstart initializes and starts an HTTPS static server with Basic authentication and access logging, demonstrating common configuration options.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}