{"id":15389,"library":"super-simple-web-server","title":"Super Simple Web Server","description":"Super Simple Web Server (super-simple-web-server) is a lightweight Node.js CLI utility designed for quickly serving static files via HTTP and HTTPS on localhost, primarily intended for development and testing purposes. Currently at version 1.1.4, with its last major update in March 2021, the package is in a maintenance state, fulfilling its specific niche without active feature development or a regular release cadence. A key feature is the inclusion of pre-generated, self-signed SSL certificates for HTTPS support, explicitly noted to be unsuitable for production environments and set to expire on June 6, 2028. It distinguishes itself by offering a \"fire-and-forget\" setup via `npm start` with optional command-line arguments for web root and custom CommonJS middleware, making it ideal for rapid prototyping or isolated local development without complex server configurations. While primarily a CLI tool, it also exposes a programmatic `startServer` function for more controlled integration within Node.js applications.","status":"maintenance","version":"1.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/garris/superSimpleExpressServer","tags":["javascript"],"install":[{"cmd":"npm install super-simple-web-server","lang":"bash","label":"npm"},{"cmd":"yarn add super-simple-web-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add super-simple-web-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core web server framework used internally to handle HTTP/HTTPS requests and serve static files.","package":"express","optional":false},{"reason":"Utilized for detecting network interfaces when `USE_LOCALHOST` is set to false, to find available IP addresses on the machine.","package":"os","optional":false},{"reason":"Provides graceful shutdown capabilities for the HTTP/HTTPS servers.","package":"http-shutdown","optional":false},{"reason":"Powers the command-line interface, parsing arguments for web root, middleware, and other options.","package":"commander","optional":false}],"imports":[{"note":"The primary programmatic interface, `startServer`, is exposed as a CommonJS named export. Direct ESM `import` is not supported for this function as the package itself does not define `\"type\": \"module\"` in its `package.json`.","wrong":"import { startServer } from 'super-simple-web-server';","symbol":"startServer","correct":"const { startServer } = require('super-simple-web-server');"},{"note":"It is possible to `require` the entire module object, with the `startServer` function available as a property. This is a standard CommonJS pattern.","symbol":"Full Module Object","correct":"const ssws = require('super-simple-web-server');\nssws.startServer(process.cwd(), null, { httpPort: 3000, httpsPort: 3001 });"},{"note":"Custom middleware files, which are loaded by the `super-simple-web-server` instance, must use CommonJS `module.exports` to expose a function that accepts the Express `app` instance. ESM `export` syntax is not supported for these middleware files.","wrong":"export default (app) => { /* ... */ };","symbol":"Middleware Function","correct":"module.exports = (app) => {\n  app.use((req, res, next) => {\n    console.log('Middleware activated for:', req.url);\n    next();\n  });\n  // Example: Add a custom route\n  app.get('/hello', (req, res) => res.send('Hello from custom middleware!'));\n};"}],"quickstart":{"code":"npm install super-simple-web-server\n\n# To serve files from the current directory on default ports (HTTP 3000, HTTPS 3001)\nnpm start\n\n# To serve files from a specific directory, e.g., './public'\nnpm start ./public\n\n# Create a middleware.js file:\n# // middleware.js\n# module.exports = (app) => {\n#   app.get('/api/data', (req, res) => res.json({ message: 'Data from API', timestamp: Date.now() }));\n# };\n\n# To serve files from './public' with custom middleware from './middleware.js'\nnpm start ./public ./middleware.js\n\n# To change default ports, e.g., HTTP on 8080, HTTPS on 8443\nSSWS_HTTP_PORT=8080 SSWS_HTTPS_PORT=8443 npm start","lang":"javascript","description":"Demonstrates installation, basic server startup, serving from a specified directory, adding custom CommonJS middleware, and configuring ports via environment variables."},"warnings":[{"fix":"For production, use a robust web server like Nginx or Apache, or a Node.js framework (e.g., Express) with properly managed and renewed certificates from a trusted Certificate Authority.","message":"This package includes self-signed SSL certificates for HTTPS support that will expire on June 6, 2028. These certificates are for development convenience ONLY and are explicitly NOT suitable for production use due to security risks.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always use battle-tested, feature-rich server solutions for production deployments. Consider `http-server` or `local-web-server` for more robust static file serving, or a full-fledged framework like Express directly for more complex applications.","message":"The server's `index.js` explicitly states 'Don't use this for production'. It is designed for simplicity and quick local development, lacking production-grade security, performance, and monitoring features.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your middleware file exports its function using `module.exports = (app) => { /* ... */ };` and not ESM syntax. The package's internal `require` mechanism expects CommonJS.","message":"Custom middleware files must strictly use CommonJS `module.exports`. Attempting to use ES Modules (`export default` or named `export`) in middleware files will result in runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"To serve on a different IP (e.g., for network access), fork the repository or manually edit the `index.js` file in your `node_modules/super-simple-web-server` directory (though not recommended for maintainability) to set `USE_LOCALHOST = false`.","message":"By default, the server binds to `127.0.0.1` (localhost). To bind to other available IP addresses on your machine, you must modify `index.js` directly by setting `USE_LOCALHOST = false`. This is not configurable via CLI arguments or environment variables.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Specify different ports using environment variables: `SSWS_HTTP_PORT=8080 SSWS_HTTPS_PORT=8443 npm start`.","cause":"The default HTTP port (3000) or HTTPS port (3001) is already in use by another application on your system.","error":"Error: listen EADDRINUSE: address already in use :::3000"},{"fix":"Verify the absolute or relative path to your middleware file. Ensure the file exists and is accessible from where you run `npm start`.","cause":"The path provided for the middleware file is incorrect or the file does not exist at the specified location.","error":"Error: Cannot find module 'path/to/some/middleware'"},{"fix":"Ensure your middleware file has `module.exports = (app) => { /* ... */ };` and that `app` is correctly passed and used within your function (e.g., `app.use(...)`, `app.get(...)`).","cause":"This error typically occurs within a custom middleware file if the `app` object (the Express application instance) is not correctly received or used, or if the middleware file does not export a function in the expected CommonJS format.","error":"TypeError: app.use is not a function"}],"ecosystem":"npm"}