-
Notifications
You must be signed in to change notification settings - Fork 87
API reference
Lloyd Brookes edited this page Jul 18, 2017
·
17 revisions
Emits: verbose
Example
const LocalWebServer = require('local-web-server')
const localWebServer = new LocalWebServer()
const server = localWebServer.listen({
port: 8050,
https: true,
directory: 'src',
spa: 'index.html',
websocket: 'src/websocket-server.js'
})
// secure, SPA server with listening websocket now ready on port 8050
Returns a listening HTTP/HTTPS server.
Kind: instance method of LocalWebServer
Param | Type | Description |
---|---|---|
[options] | object |
Server options |
[options.port] | number |
Port |
[options.hostname] | string |
The hostname (or IP address) to listen on. Defaults to 0.0.0.0. |
[options.maxConnections] | number |
The maximum number of concurrent connections supported by the server. |
[options.keepAliveTimeout] | number |
The period (in milliseconds) of inactivity a connection will remain open before being destroyed. Set to 0 to keep connections open indefinitely. |
[options.configFile] | string |
Config file path, defaults to 'lws.config.js'. |
[options.https] | boolean |
Enable HTTPS using a built-in key and cert registered to the domain 127.0.0.1. |
[options.key] | string |
SSL key file path. Supply along with --cert to launch a https server. |
[options.cert] | string |
SSL cert file path. Supply along with --key to launch a https server. |
[options.pfx] | string |
Path to an PFX or PKCS12 encoded private key and certificate chain. An alternative to providing --key and --cert. |
[options.ciphers] | string |
Optional cipher suite specification, replacing the default. |
[options.secureProtocol] | string |
Optional SSL method to use, default is "SSLv23_method". |
[options.stack] |
Array.<string> | Array.<Middlewares>
|
Array of feature classes, or filenames of modules exporting a feature class. |
[options.server] |
string | ServerFactory
|
Custom server factory, e.g. lws-http2. |
[options.websocket] |
string | Websocket
|
Path to a websocket module |
[options.moduleDir] | Array.<string> |
One or more directories to search for modules. |
Highly-verbose debug information event stream.
Kind: event emitted by LocalWebServer
Param | Type | Description |
---|---|---|
key | string |
An identifying string, e.g. server.socket.data . |
value | * |
The value, e.g. { socketId: 1, bytesRead: '3 Kb' } . |