You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.8 KiB

  1. <a name="module_local-web-server"></a>
  2. ## local-web-server
  3. **Emits**: <code>module:local-web-server#event:verbose</code>
  4. **Example**
  5. ```js
  6. const LocalWebServer = require('local-web-server')
  7. const localWebServer = new LocalWebServer()
  8. const server = localWebServer.listen({
  9. port: 8050,
  10. https: true,
  11. directory: 'src',
  12. spa: 'index.html',
  13. websocket: 'src/websocket-server.js'
  14. })
  15. // secure, SPA server with listening websocket now ready on port 8050
  16. ```
  17. * [local-web-server](#module_local-web-server)
  18. * [LocalWebServer](#exp_module_local-web-server--LocalWebServer) ⏏
  19. * [.listen([options])](#module_local-web-server--LocalWebServer+listen) ⇒ <code>Server</code>
  20. <a name="exp_module_local-web-server--LocalWebServer"></a>
  21. ### LocalWebServer ⏏
  22. **Kind**: Exported class
  23. <a name="module_local-web-server--LocalWebServer+listen"></a>
  24. #### localWebServer.listen([options]) ⇒ <code>Server</code>
  25. Returns a listening HTTP/HTTPS server.
  26. **Kind**: instance method of [<code>LocalWebServer</code>](#exp_module_local-web-server--LocalWebServer)
  27. **Params**
  28. - [options] <code>object</code> - Server options
  29. - [.port] <code>number</code> - Port
  30. - [.hostname] <code>string</code> - The hostname (or IP address) to listen on. Defaults to 0.0.0.0.
  31. - [.maxConnections] <code>number</code> - The maximum number of concurrent connections supported by the server.
  32. - [.keepAliveTimeout] <code>number</code> - The period (in milliseconds) of inactivity a connection will remain open before being destroyed. Set to `0` to keep connections open indefinitely.
  33. - [.configFile] <code>string</code> - Config file path, defaults to 'lws.config.js'.
  34. - [.https] <code>boolean</code> - Enable HTTPS using a built-in key and cert registered to the domain 127.0.0.1.
  35. - [.key] <code>string</code> - SSL key file path. Supply along with --cert to launch a https server.
  36. - [.cert] <code>string</code> - SSL cert file path. Supply along with --key to launch a https server.
  37. - [.pfx] <code>string</code> - Path to an PFX or PKCS12 encoded private key and certificate chain. An alternative to providing --key and --cert.
  38. - [.ciphers] <code>string</code> - Optional cipher suite specification, replacing the default.
  39. - [.secureProtocol] <code>string</code> - Optional SSL method to use, default is "SSLv23_method".
  40. - [.stack] <code>Array.&lt;string&gt;</code> | <code>Array.&lt;Middlewares&gt;</code> - Array of feature classes, or filenames of modules exporting a feature class.
  41. - [.server] <code>string</code> | <code>ServerFactory</code> - Custom server factory, e.g. lws-http2.
  42. - [.websocket] <code>string</code> | <code>Websocket</code> - Path to a websocket module
  43. - [.moduleDir] <code>Array.&lt;string&gt;</code> - One or more directories to search for modules.