@stdlib/net-http-server 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.js.map +2 -2
- package/lib/main.js +1 -1
- package/package.json +11 -22
package/README.md
CHANGED
|
@@ -229,8 +229,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
229
229
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/net-http-server.svg
|
|
230
230
|
[npm-url]: https://npmjs.org/package/@stdlib/net-http-server
|
|
231
231
|
|
|
232
|
-
[test-image]: https://github.com/stdlib-js/net-http-server/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
233
|
-
[test-url]: https://github.com/stdlib-js/net-http-server/actions/workflows/test.yml?query=branch:v0.2.
|
|
232
|
+
[test-image]: https://github.com/stdlib-js/net-http-server/actions/workflows/test.yml/badge.svg?branch=v0.2.2
|
|
233
|
+
[test-url]: https://github.com/stdlib-js/net-http-server/actions/workflows/test.yml?query=branch:v0.2.2
|
|
234
234
|
|
|
235
235
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/net-http-server/main.svg
|
|
236
236
|
[coverage-url]: https://codecov.io/github/stdlib-js/net-http-server?branch=main
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/validate.js", "../lib/defaults.json", "../lib/main.js", "../lib/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {NonNegativeInteger} [options.port] - server port\n* @param {NonNegativeInteger} [options.maxport] - max server port\n* @param {string} [options.hostname] - server hostname\n* @param {string} [options.address] - server address\n* @returns {(Error|null)} error or null\n*\n* @example\n* var options = {\n* 'port': 7331,\n* 'address': '127.0.0.1'\n* };\n* var opts = {};\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'port' ) ) {\n\t\topts.port = options.port;\n\t\tif ( !isNonNegativeInteger( opts.port ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'port', opts.port ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'maxport' ) ) {\n\t\topts.maxport = options.maxport;\n\t\tif ( !isNonNegativeInteger( opts.maxport ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'maxport', opts.maxport ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'hostname' ) ) {\n\t\topts.hostname = options.hostname;\n\t\tif ( !isString( opts.hostname ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'hostname', opts.hostname ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'address' ) ) {\n\t\topts.address = options.address;\n\t\tif ( !isString( opts.address ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'address', opts.address ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "{\n\t\"port\": 0,\n\t\"address\": \"127.0.0.1\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar http = require( 'http' );\nvar logger = require( 'debug' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\nvar validate = require( './validate.js' );\nvar DEFAULTS = require( './defaults.json' );\n\n\n// VARIABLES //\n\nvar debug = logger( '@stdlib/net-http-server');\n\n\n// MAIN //\n\n/**\n* Returns a function which creates an HTTP server.\n*\n* @param {Options} [options] - server options\n* @param {NonNegativeInteger} [options.port=0] - server port\n* @param {NonNegativeInteger} [options.maxport] - max server port\n* @param {string} [options.hostname] - server hostname\n* @param {string} [options.address=\"127.0.0.1\"] - server address\n* @param {Callback} [requestListener] - callback invoked upon receiving an HTTP request\n* @throws {TypeError} `requestListener` must be a function\n* @throws {TypeError} must provide valid options\n* @returns {Function} function which creates an HTTP server\n*\n* @example\n* var createServer = httpServer();\n*\n* @example\n* var opts = {\n* 'port': 7331,\n* 'address': '0.0.0.0'\n* };\n* var createServer = httpServer( opts );\n*\n* @example\n* var opts = {\n* 'port': 7331,\n* 'address': '0.0.0.0'\n* };\n* function onRequest( request, response ) {\n* console.log( request.url );\n* response.end( 'OK' );\n* }\n* var createServer = httpServer( opts, onRequest );\n*/\nfunction httpServer() {\n\tvar requestListener;\n\tvar hostname;\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar port;\n\tvar max;\n\tvar err;\n\n\tnargs = arguments.length;\n\topts = {};\n\tif ( nargs === 1 ) {\n\t\tif ( isFunction( arguments[0] )) {\n\t\t\trequestListener = arguments[ 0 ];\n\t\t} else {\n\t\t\toptions = arguments[ 0 ];\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\telse if ( nargs > 1 ) {\n\t\toptions = arguments[ 0 ];\n\t\trequestListener = arguments[ 1 ];\n\t\tif ( !isFunction( requestListener ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Request listener must be a function. Value: `%s`.', requestListener ) );\n\t\t}\n\t\terr = validate( opts, options );\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.port === void 0 ) {\n\t\tport = DEFAULTS.port;\n\t} else {\n\t\tport = opts.port;\n\t}\n\tdebug( 'Server port: %d', port );\n\n\tif ( opts.maxport === void 0 ) {\n\t\tmax = port;\n\t} else {\n\t\tmax = opts.maxport;\n\t}\n\tdebug( 'Max server port: %d', max );\n\n\tif ( opts.hostname ) {\n\t\thostname = opts.hostname;\n\t}\n\telse if ( opts.address ) {\n\t\thostname = opts.address;\n\t}\n\telse {\n\t\thostname = DEFAULTS.address;\n\t}\n\tdebug( 'Server hostname: %s', hostname );\n\n\treturn createServer;\n\n\t/**\n\t* Creates an HTTP server.\n\t*\n\t* @private\n\t* @param {Callback} done - function to invoke after creating a server\n\t* @throws {TypeError} must provide a function\n\t*\n\t* @example\n\t* function done( error, server ) {\n\t* if ( error ) {\n\t* throw error;\n\t* }\n\t* console.log( 'Success!' );\n\t* server.close();\n\t* }\n\t* createServer( done );\n\t*/\n\tfunction createServer( done ) {\n\t\tvar server;\n\t\tif ( !isFunction( done ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', done ) );\n\t\t}\n\t\tif ( requestListener ) {\n\t\t\tserver = http.createServer( requestListener );\n\t\t} else {\n\t\t\tserver = http.createServer();\n\t\t}\n\t\tserver.on( 'error', errorListener );\n\t\tserver.once( 'listening', onListen );\n\n\t\tdebug( 'Attempting to listen on %s:%d.', hostname, port );\n\t\tserver.listen( port, hostname );\n\n\t\t/**\n\t\t* Server error event handler.\n\t\t*\n\t\t* @private\n\t\t* @param {Error} error - server error\n\t\t* @throws {Error} server error\n\t\t*/\n\t\tfunction errorListener( error ) {\n\t\t\tif ( error.code === 'EADDRINUSE' ) {\n\t\t\t\tdebug( 'Server address already in use: %s:%d.', hostname, port );\n\t\t\t\tport += 1;\n\t\t\t\tif ( port <= max ) {\n\t\t\t\t\tdebug( 'Attempting to listen on %s:%d.', hostname, port );\n\t\t\t\t\tserver.listen( port, hostname );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\t/**\n\t\t* Callback invoked once a server is listening and ready to handle requests.\n\t\t*\n\t\t* @private\n\t\t*/\n\t\tfunction onListen() {\n\t\t\tvar addr = server.address();\n\t\t\tdebug( 'HTTP server initialized. Server is listening for requests on %s:%d.', addr.address, addr.port );\n\t\t\tdone( null, server );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = httpServer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an HTTP server.\n*\n* @module @stdlib/net-http-server\n*\n* @example\n* var httpServer = require( '@stdlib/net-http-server' );\n*\n* var opts = {\n* 'port': 7331,\n* 'address': '0.0.0.0'\n* };\n* function done( error, server ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( 'Success!' );\n* server.close();\n* }\n* var createServer = httpServer( opts );\n* createServer( done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAS,QAAS,uBAAwB,EA4B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAML,EAAUK,CAAQ,EAGnBJ,EAAYI,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACP,EAAsBM,EAAK,IAAK,GAC9B,IAAI,UAAWF,EAAQ,2EAA4E,OAAQE,EAAK,IAAK,CAAE,EAG3HH,EAAYI,EAAS,SAAU,IACnCD,EAAK,QAAUC,EAAQ,QAClB,CAACP,EAAsBM,EAAK,OAAQ,GACjC,IAAI,UAAWF,EAAQ,2EAA4E,UAAWE,EAAK,OAAQ,CAAE,EAGjIH,EAAYI,EAAS,UAAW,IACpCD,EAAK,SAAWC,EAAQ,SACnB,CAACN,EAAUK,EAAK,QAAS,GACtB,IAAI,UAAWF,EAAQ,8DAA+D,WAAYE,EAAK,QAAS,CAAE,EAGtHH,EAAYI,EAAS,SAAU,IACnCD,EAAK,QAAUC,EAAQ,QAClB,CAACN,EAAUK,EAAK,OAAQ,GACrB,IAAI,UAAWF,EAAQ,8DAA+D,UAAWE,EAAK,OAAQ,CAAE,EAGlH,KA1BC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CA2BhH,CAKAR,EAAO,QAAUM,ICxFjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,KAAQ,EACR,QAAW,WACZ,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,MAAO,EACvBC,EAAS,QAAS,OAAQ,EAC1BC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAW,IACXC,EAAW,IAKXC,EAAQL,EAAQ,
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {NonNegativeInteger} [options.port] - server port\n* @param {NonNegativeInteger} [options.maxport] - max server port\n* @param {string} [options.hostname] - server hostname\n* @param {string} [options.address] - server address\n* @returns {(Error|null)} error or null\n*\n* @example\n* var options = {\n* 'port': 7331,\n* 'address': '127.0.0.1'\n* };\n* var opts = {};\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'port' ) ) {\n\t\topts.port = options.port;\n\t\tif ( !isNonNegativeInteger( opts.port ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'port', opts.port ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'maxport' ) ) {\n\t\topts.maxport = options.maxport;\n\t\tif ( !isNonNegativeInteger( opts.maxport ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'maxport', opts.maxport ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'hostname' ) ) {\n\t\topts.hostname = options.hostname;\n\t\tif ( !isString( opts.hostname ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'hostname', opts.hostname ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'address' ) ) {\n\t\topts.address = options.address;\n\t\tif ( !isString( opts.address ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'address', opts.address ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "{\n\t\"port\": 0,\n\t\"address\": \"127.0.0.1\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar http = require( 'http' );\nvar logger = require( 'debug' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\nvar validate = require( './validate.js' );\nvar DEFAULTS = require( './defaults.json' );\n\n\n// VARIABLES //\n\nvar debug = logger( '@stdlib/net-http-server' );\n\n\n// MAIN //\n\n/**\n* Returns a function which creates an HTTP server.\n*\n* @param {Options} [options] - server options\n* @param {NonNegativeInteger} [options.port=0] - server port\n* @param {NonNegativeInteger} [options.maxport] - max server port\n* @param {string} [options.hostname] - server hostname\n* @param {string} [options.address=\"127.0.0.1\"] - server address\n* @param {Callback} [requestListener] - callback invoked upon receiving an HTTP request\n* @throws {TypeError} `requestListener` must be a function\n* @throws {TypeError} must provide valid options\n* @returns {Function} function which creates an HTTP server\n*\n* @example\n* var createServer = httpServer();\n*\n* @example\n* var opts = {\n* 'port': 7331,\n* 'address': '0.0.0.0'\n* };\n* var createServer = httpServer( opts );\n*\n* @example\n* var opts = {\n* 'port': 7331,\n* 'address': '0.0.0.0'\n* };\n* function onRequest( request, response ) {\n* console.log( request.url );\n* response.end( 'OK' );\n* }\n* var createServer = httpServer( opts, onRequest );\n*/\nfunction httpServer() {\n\tvar requestListener;\n\tvar hostname;\n\tvar options;\n\tvar nargs;\n\tvar opts;\n\tvar port;\n\tvar max;\n\tvar err;\n\n\tnargs = arguments.length;\n\topts = {};\n\tif ( nargs === 1 ) {\n\t\tif ( isFunction( arguments[0] )) {\n\t\t\trequestListener = arguments[ 0 ];\n\t\t} else {\n\t\t\toptions = arguments[ 0 ];\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\telse if ( nargs > 1 ) {\n\t\toptions = arguments[ 0 ];\n\t\trequestListener = arguments[ 1 ];\n\t\tif ( !isFunction( requestListener ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Request listener must be a function. Value: `%s`.', requestListener ) );\n\t\t}\n\t\terr = validate( opts, options );\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.port === void 0 ) {\n\t\tport = DEFAULTS.port;\n\t} else {\n\t\tport = opts.port;\n\t}\n\tdebug( 'Server port: %d', port );\n\n\tif ( opts.maxport === void 0 ) {\n\t\tmax = port;\n\t} else {\n\t\tmax = opts.maxport;\n\t}\n\tdebug( 'Max server port: %d', max );\n\n\tif ( opts.hostname ) {\n\t\thostname = opts.hostname;\n\t}\n\telse if ( opts.address ) {\n\t\thostname = opts.address;\n\t}\n\telse {\n\t\thostname = DEFAULTS.address;\n\t}\n\tdebug( 'Server hostname: %s', hostname );\n\n\treturn createServer;\n\n\t/**\n\t* Creates an HTTP server.\n\t*\n\t* @private\n\t* @param {Callback} done - function to invoke after creating a server\n\t* @throws {TypeError} must provide a function\n\t*\n\t* @example\n\t* function done( error, server ) {\n\t* if ( error ) {\n\t* throw error;\n\t* }\n\t* console.log( 'Success!' );\n\t* server.close();\n\t* }\n\t* createServer( done );\n\t*/\n\tfunction createServer( done ) {\n\t\tvar server;\n\t\tif ( !isFunction( done ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', done ) );\n\t\t}\n\t\tif ( requestListener ) {\n\t\t\tserver = http.createServer( requestListener );\n\t\t} else {\n\t\t\tserver = http.createServer();\n\t\t}\n\t\tserver.on( 'error', errorListener );\n\t\tserver.once( 'listening', onListen );\n\n\t\tdebug( 'Attempting to listen on %s:%d.', hostname, port );\n\t\tserver.listen( port, hostname );\n\n\t\t/**\n\t\t* Server error event handler.\n\t\t*\n\t\t* @private\n\t\t* @param {Error} error - server error\n\t\t* @throws {Error} server error\n\t\t*/\n\t\tfunction errorListener( error ) {\n\t\t\tif ( error.code === 'EADDRINUSE' ) {\n\t\t\t\tdebug( 'Server address already in use: %s:%d.', hostname, port );\n\t\t\t\tport += 1;\n\t\t\t\tif ( port <= max ) {\n\t\t\t\t\tdebug( 'Attempting to listen on %s:%d.', hostname, port );\n\t\t\t\t\tserver.listen( port, hostname );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\t/**\n\t\t* Callback invoked once a server is listening and ready to handle requests.\n\t\t*\n\t\t* @private\n\t\t*/\n\t\tfunction onListen() {\n\t\t\tvar addr = server.address();\n\t\t\tdebug( 'HTTP server initialized. Server is listening for requests on %s:%d.', addr.address, addr.port );\n\t\t\tdone( null, server );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = httpServer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an HTTP server.\n*\n* @module @stdlib/net-http-server\n*\n* @example\n* var httpServer = require( '@stdlib/net-http-server' );\n*\n* var opts = {\n* 'port': 7331,\n* 'address': '0.0.0.0'\n* };\n* function done( error, server ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( 'Success!' );\n* server.close();\n* }\n* var createServer = httpServer( opts );\n* createServer( done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAS,QAAS,uBAAwB,EA4B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAML,EAAUK,CAAQ,EAGnBJ,EAAYI,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACP,EAAsBM,EAAK,IAAK,GAC9B,IAAI,UAAWF,EAAQ,2E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["require_validate", "__commonJSMin", "exports", "module", "isNonNegativeInteger", "isString", "isObject", "hasOwnProp", "format", "validate", "opts", "options", "require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "http", "logger", "isFunction", "format", "validate", "DEFAULTS", "debug", "httpServer", "requestListener", "hostname", "options", "nargs", "opts", "port", "max", "err", "createServer", "done", "server", "errorListener", "onListen", "error", "addr", "main"]
|
|
7
7
|
}
|
package/lib/main.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/net-http-server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "HTTP server.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -16,16 +16,11 @@
|
|
|
16
16
|
"main": "./lib",
|
|
17
17
|
"directories": {
|
|
18
18
|
"doc": "./docs",
|
|
19
|
-
"example": "./examples",
|
|
20
19
|
"lib": "./lib",
|
|
21
|
-
"
|
|
20
|
+
"dist": "./dist"
|
|
22
21
|
},
|
|
23
22
|
"types": "./docs/types",
|
|
24
|
-
"scripts": {
|
|
25
|
-
"test": "make test",
|
|
26
|
-
"test-cov": "make test-cov",
|
|
27
|
-
"examples": "make examples"
|
|
28
|
-
},
|
|
23
|
+
"scripts": {},
|
|
29
24
|
"homepage": "https://stdlib.io",
|
|
30
25
|
"repository": {
|
|
31
26
|
"type": "git",
|
|
@@ -35,22 +30,16 @@
|
|
|
35
30
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
36
31
|
},
|
|
37
32
|
"dependencies": {
|
|
38
|
-
"@stdlib/assert-has-own-property": "^0.
|
|
39
|
-
"@stdlib/assert-is-function": "^0.2.
|
|
40
|
-
"@stdlib/assert-is-nonnegative-integer": "^0.2.
|
|
41
|
-
"@stdlib/assert-is-plain-object": "^0.2.
|
|
42
|
-
"@stdlib/assert-is-string": "^0.2.
|
|
43
|
-
"@stdlib/string-format": "^0.2.
|
|
33
|
+
"@stdlib/assert-has-own-property": "^0.2.2",
|
|
34
|
+
"@stdlib/assert-is-function": "^0.2.2",
|
|
35
|
+
"@stdlib/assert-is-nonnegative-integer": "^0.2.1",
|
|
36
|
+
"@stdlib/assert-is-plain-object": "^0.2.2",
|
|
37
|
+
"@stdlib/assert-is-string": "^0.2.2",
|
|
38
|
+
"@stdlib/string-format": "^0.2.2",
|
|
44
39
|
"debug": "^2.6.9",
|
|
45
|
-
"@stdlib/error-tools-fmtprodmsg": "^0.
|
|
46
|
-
},
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"@stdlib/utils-keys": "^0.1.0",
|
|
49
|
-
"@stdlib/utils-noop": "^0.2.0",
|
|
50
|
-
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
51
|
-
"istanbul": "^0.4.1",
|
|
52
|
-
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
|
40
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.2.2"
|
|
53
41
|
},
|
|
42
|
+
"devDependencies": {},
|
|
54
43
|
"engines": {
|
|
55
44
|
"node": ">=0.10.0",
|
|
56
45
|
"npm": ">2.7.0"
|