@stdlib/net-http-server 0.0.7 → 0.1.0

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/CITATION.cff ADDED
@@ -0,0 +1,30 @@
1
+ cff-version: 1.2.0
2
+ title: stdlib
3
+ message: >-
4
+ If you use this software, please cite it using the
5
+ metadata from this file.
6
+
7
+ type: software
8
+
9
+ authors:
10
+ - name: The Stdlib Authors
11
+ url: https://github.com/stdlib-js/stdlib/graphs/contributors
12
+
13
+ repository-code: https://github.com/stdlib-js/stdlib
14
+ url: https://stdlib.io
15
+
16
+ abstract: |
17
+ Standard library for JavaScript and Node.js.
18
+
19
+ keywords:
20
+ - JavaScript
21
+ - Node.js
22
+ - TypeScript
23
+ - standard library
24
+ - scientific computing
25
+ - numerical computing
26
+ - statistical computing
27
+
28
+ license: Apache-2.0 AND BSL-1.0
29
+
30
+ date-released: 2016
package/LICENSE CHANGED
@@ -175,307 +175,3 @@
175
175
  of your accepting any such warranty or additional liability.
176
176
 
177
177
  END OF TERMS AND CONDITIONS
178
-
179
-
180
-
181
- Boost Software License - Version 1.0 - August 17th, 2003
182
-
183
- Permission is hereby granted, free of charge, to any person or organization
184
- obtaining a copy of the software and accompanying documentation covered by this
185
- license (the "Software") to use, reproduce, display, distribute, execute, and
186
- transmit the Software, and to prepare derivative works of the Software, and to
187
- permit third-parties to whom the Software is furnished to do so, all subject to
188
- the following:
189
-
190
- The copyright notices in the Software and this entire statement, including the
191
- above license grant, this restriction and the following disclaimer, must be
192
- included in all copies of the Software, in whole or in part, and all derivative
193
- works of the Software, unless such copies or derivative works are solely in the
194
- form of machine-executable object code generated by a source language processor.
195
-
196
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
197
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
198
- FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
199
- COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
200
- OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
201
- OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
202
-
203
-
204
-
205
-
206
- DEPENDENCIES
207
-
208
- The library links against the following external libraries, which have their own
209
- licenses:
210
-
211
- * OpenBLAS <https://raw.githubusercontent.com/xianyi/OpenBLAS/
212
- def146efed8d5908ea04e22668feeab7099599a0/LICENSE>
213
-
214
- Copyright (c) 2011-2014, The OpenBLAS Project
215
- All rights reserved.
216
-
217
- Redistribution and use in source and binary forms, with or without
218
- modification, are permitted provided that the following conditions are
219
- met:
220
-
221
- 1. Redistributions of source code must retain the above copyright
222
- notice, this list of conditions and the following disclaimer.
223
-
224
- 2. Redistributions in binary form must reproduce the above copyright
225
- notice, this list of conditions and the following disclaimer in
226
- the documentation and/or other materials provided with the
227
- distribution.
228
-
229
- 3. Neither the name of the OpenBLAS project nor the names of
230
- its contributors may be used to endorse or promote products
231
- derived from this software without specific prior written
232
- permission.
233
-
234
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
235
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
236
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
237
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
238
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
239
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
240
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
242
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
243
- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
244
-
245
-
246
- * Electron <https://raw.githubusercontent.com/electron/electron/
247
- c4cfb3e7110266b9d7ad80e1ae097c4db564501c/LICENSE>
248
-
249
- Copyright (c) 2013-2017 GitHub Inc.
250
-
251
- Permission is hereby granted, free of charge, to any person obtaining
252
- a copy of this software and associated documentation files (the
253
- "Software"), to deal in the Software without restriction, including
254
- without limitation the rights to use, copy, modify, merge, publish,
255
- distribute, sublicense, and/or sell copies of the Software, and to
256
- permit persons to whom the Software is furnished to do so, subject to
257
- the following conditions:
258
-
259
- The above copyright notice and this permission notice shall be
260
- included in all copies or substantial portions of the Software.
261
-
262
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
263
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
264
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
265
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
266
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
267
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
268
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
269
-
270
-
271
- * Boost <http://www.boost.org/LICENSE_1_0.txt>
272
-
273
- Boost Software License - Version 1.0 - August 17th, 2003
274
-
275
- Permission is hereby granted, free of charge, to any person or organization
276
- obtaining a copy of the software and accompanying documentation covered by
277
- this license (the "Software") to use, reproduce, display, distribute,
278
- execute, and transmit the Software, and to prepare derivative works of the
279
- Software, and to permit third-parties to whom the Software is furnished to
280
- do so, all subject to the following:
281
-
282
- The copyright notices in the Software and this entire statement, including
283
- the above license grant, this restriction and the following disclaimer,
284
- must be included in all copies of the Software, in whole or in part, and
285
- all derivative works of the Software, unless such copies or derivative
286
- works are solely in the form of machine-executable object code generated by
287
- a source language processor.
288
-
289
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
290
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
291
- FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
292
- SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
293
- FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
294
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
295
- DEALINGS IN THE SOFTWARE.
296
-
297
-
298
- * Cephes <http://www.netlib.org/cephes/readme>
299
-
300
- Copyright (c) 1984-2000 Stephen L. Moshier
301
-
302
- Some software in this archive may be from the book _Methods and Programs for
303
- Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989)
304
- or from the Cephes Mathematical Library, a commercial product. In either event,
305
- it is copyrighted by the author. What you see here may be used freely but it
306
- comes with no support or guarantee.
307
-
308
- Stephen L. Moshier
309
- moshier@na-net.ornl.gov
310
-
311
-
312
-
313
- ATTRIBUTION
314
-
315
- The library contains implementations from the following external libraries,
316
- which have their own licenses:
317
-
318
- * FreeBSD <https://svnweb.freebsd.org/>
319
-
320
- Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
321
-
322
- Developed at SunPro, a Sun Microsystems, Inc. business.
323
- Permission to use, copy, modify, and distribute this
324
- software is freely granted, provided that this notice
325
- is preserved.
326
-
327
-
328
- * FDLIBM <http://www.netlib.org/fdlibm/>
329
-
330
- Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
331
-
332
- Developed at SunPro, a Sun Microsystems, Inc. business.
333
- Permission to use, copy, modify, and distribute this
334
- software is freely granted, provided that this notice
335
- is preserved.
336
-
337
-
338
- * Go <https://raw.githubusercontent.com/golang/go/master/LICENSE>
339
-
340
- Copyright (c) 2009 The Go Authors. All rights reserved.
341
-
342
- Redistribution and use in source and binary forms, with or without
343
- modification, are permitted provided that the following conditions are
344
- met:
345
-
346
- * Redistributions of source code must retain the above copyright
347
- notice, this list of conditions and the following disclaimer.
348
- * Redistributions in binary form must reproduce the above
349
- copyright notice, this list of conditions and the following disclaimer
350
- in the documentation and/or other materials provided with the
351
- distribution.
352
- * Neither the name of Google Inc. nor the names of its
353
- contributors may be used to endorse or promote products derived from
354
- this software without specific prior written permission.
355
-
356
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
357
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
358
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
359
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
360
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
361
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
362
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
363
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
364
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
365
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
366
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
367
-
368
-
369
- * SLATEC Common Mathematical Library <http://www.netlib.no/netlib/slatec/>
370
-
371
- Public domain.
372
-
373
-
374
- * ESLint <https://raw.githubusercontent.com/eslint/eslint/master/LICENSE>
375
-
376
- Copyright JS Foundation and other contributors, https://js.foundation
377
-
378
- Permission is hereby granted, free of charge, to any person obtaining a copy
379
- of this software and associated documentation files (the "Software"), to deal
380
- in the Software without restriction, including without limitation the rights
381
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
382
- copies of the Software, and to permit persons to whom the Software is
383
- furnished to do so, subject to the following conditions:
384
-
385
- The above copyright notice and this permission notice shall be included in
386
- all copies or substantial portions of the Software.
387
-
388
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
389
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
390
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
391
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
392
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
393
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
394
- THE SOFTWARE.
395
-
396
-
397
- * StatsFuns.jl <https://raw.githubusercontent.com/JuliaStats/StatsFuns.jl/
398
- e66dd973650c375bc1739c820e5b96bb5bd000a8/LICENSE.md>
399
-
400
- Copyright (c) 2015: Dahua Lin.
401
-
402
- Permission is hereby granted, free of charge, to any person obtaining
403
- a copy of this software and associated documentation files (the
404
- "Software"), to deal in the Software without restriction, including
405
- without limitation the rights to use, copy, modify, merge, publish,
406
- distribute, sublicense, and/or sell copies of the Software, and to
407
- permit persons to whom the Software is furnished to do so, subject to
408
- the following conditions:
409
-
410
- The above copyright notice and this permission notice shall be
411
- included in all copies or substantial portions of the Software.
412
-
413
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
414
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
415
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
416
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
417
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
418
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
419
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
420
-
421
-
422
- * SpecialFunctions.jl <https://raw.githubusercontent.com/JuliaMath/
423
- SpecialFunctions.jl/02a173fbe24a61c4b392aec17a9764ac5727feb1/LICENSE>
424
-
425
- The MIT License (MIT)
426
-
427
- Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others:
428
-
429
- https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors
430
-
431
- Permission is hereby granted, free of charge, to any person obtaining a copy
432
- of this software and associated documentation files (the "Software"), to deal
433
- in the Software without restriction, including without limitation the rights
434
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
435
- copies of the Software, and to permit persons to whom the Software is
436
- furnished to do so, subject to the following conditions:
437
-
438
- The above copyright notice and this permission notice shall be included in all
439
- copies or substantial portions of the Software.
440
-
441
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
442
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
443
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
444
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
445
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
446
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
447
- SOFTWARE.
448
-
449
-
450
- * MT19937 <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/
451
- mt19937ar.c>
452
-
453
- Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
454
- All rights reserved.
455
-
456
- Redistribution and use in source and binary forms, with or without
457
- modification, are permitted provided that the following conditions
458
- are met:
459
-
460
- 1. Redistributions of source code must retain the above copyright
461
- notice, this list of conditions and the following disclaimer.
462
-
463
- 2. Redistributions in binary form must reproduce the above copyright
464
- notice, this list of conditions and the following disclaimer in the
465
- documentation and/or other materials provided with the distribution.
466
-
467
- 3. The names of its contributors may not be used to endorse or promote
468
- products derived from this software without specific prior written
469
- permission.
470
-
471
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
472
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
473
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
474
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
475
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
476
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
477
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
478
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
479
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
480
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
481
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2021 The Stdlib Authors.
1
+ Copyright (c) 2016-2023 The Stdlib Authors.
package/README.md CHANGED
@@ -18,9 +18,20 @@ limitations under the License.
18
18
 
19
19
  -->
20
20
 
21
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
21
32
  # HTTP Server
22
33
 
23
- [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
34
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
24
35
 
25
36
  > [HTTP][http] server.
26
37
 
@@ -127,7 +138,7 @@ createServer( done );
127
138
 
128
139
  ## Examples
129
140
 
130
- <!-- eslint-disable no-process-exit -->
141
+ <!-- eslint-disable node/no-process-exit -->
131
142
 
132
143
  <!-- eslint no-undef: "error" -->
133
144
 
@@ -171,6 +182,16 @@ createServer( done );
171
182
 
172
183
  <!-- /.examples -->
173
184
 
185
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
186
+
187
+ <section class="related">
188
+
189
+ </section>
190
+
191
+ <!-- /.related -->
192
+
193
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
194
+
174
195
 
175
196
  <section class="main-repo" >
176
197
 
@@ -195,7 +216,7 @@ See [LICENSE][stdlib-license].
195
216
 
196
217
  ## Copyright
197
218
 
198
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
219
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
199
220
 
200
221
  </section>
201
222
 
@@ -208,22 +229,34 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
208
229
  [npm-image]: http://img.shields.io/npm/v/@stdlib/net-http-server.svg
209
230
  [npm-url]: https://npmjs.org/package/@stdlib/net-http-server
210
231
 
211
- [test-image]: https://github.com/stdlib-js/net-http-server/actions/workflows/test.yml/badge.svg
212
- [test-url]: https://github.com/stdlib-js/net-http-server/actions/workflows/test.yml
232
+ [test-image]: https://github.com/stdlib-js/net-http-server/actions/workflows/test.yml/badge.svg?branch=v0.1.0
233
+ [test-url]: https://github.com/stdlib-js/net-http-server/actions/workflows/test.yml?query=branch:v0.1.0
213
234
 
214
235
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/net-http-server/main.svg
215
236
  [coverage-url]: https://codecov.io/github/stdlib-js/net-http-server?branch=main
216
237
 
238
+ <!--
239
+
217
240
  [dependencies-image]: https://img.shields.io/david/stdlib-js/net-http-server.svg
218
241
  [dependencies-url]: https://david-dm.org/stdlib-js/net-http-server/main
219
242
 
243
+ -->
244
+
220
245
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
221
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
246
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
222
247
 
223
248
  [stdlib]: https://github.com/stdlib-js/stdlib
224
249
 
225
250
  [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
226
251
 
252
+ [umd]: https://github.com/umdjs/umd
253
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
254
+
255
+ [deno-url]: https://github.com/stdlib-js/net-http-server/tree/deno
256
+ [umd-url]: https://github.com/stdlib-js/net-http-server/tree/umd
257
+ [esm-url]: https://github.com/stdlib-js/net-http-server/tree/esm
258
+ [branches-url]: https://github.com/stdlib-js/net-http-server/blob/main/branches.md
259
+
227
260
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/net-http-server/main/LICENSE
228
261
 
229
262
  [http]: https://nodejs.org/api/http.html
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import httpServer from '../docs/types/index';
3
+ export = httpServer;
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var x=f(function(U,q){
2
+ var c=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,h=require('@stdlib/assert-is-string/dist').isPrimitive,D=require('@stdlib/assert-is-plain-object/dist'),m=require('@stdlib/assert-has-own-property/dist'),o=require('@stdlib/error-tools-fmtprodmsg/dist');function N(e,r){return D(r)?m(r,"port")&&(e.port=r.port,!c(e.port))?new TypeError(o('0kN2t',"port",e.port)):m(r,"maxport")&&(e.maxport=r.maxport,!c(e.maxport))?new TypeError(o('0kN2t',"maxport",e.maxport)):m(r,"hostname")&&(e.hostname=r.hostname,!h(e.hostname))?new TypeError(o('0kN2W',"hostname",e.hostname)):m(r,"address")&&(e.address=r.address,!h(e.address))?new TypeError(o('0kN2W',"address",e.address)):null:new TypeError(o('0kN2V',r));}q.exports=N
3
+ });var b=f(function(k,V){V.exports={port:0,address:"127.0.0.1"}});var O=f(function(z,y){
4
+ var w=require("http"),j=require("debug"),g=require('@stdlib/assert-is-function/dist'),S=require('@stdlib/error-tools-fmtprodmsg/dist'),E=x(),T=b(),n=j("@stdlib/net-http-server");function F(){var e,r,u,l,t,i,v,d;if(l=arguments.length,t={},l===1)g(arguments[0])?e=arguments[0]:(u=arguments[0],d=E(t,u));else if(l>1){if(u=arguments[0],e=arguments[1],!g(e))throw new TypeError(S('0kN5w',e));d=E(t,u)}if(d)throw d;return t.port===void 0?i=T.port:i=t.port,n("Server port: %d",i),t.maxport===void 0?v=i:v=t.maxport,n("Max server port: %d",v),t.hostname?r=t.hostname:t.address?r=t.address:r=T.address,n("Server hostname: %s",r),A;function A(p){var a;if(!g(p))throw new TypeError(S('0kN2b',p));e?a=w.createServer(e):a=w.createServer(),a.on("error",L),a.once("listening",P),n("Attempting to listen on %s:%d.",r,i),a.listen(i,r);function L(s){if(s.code==="EADDRINUSE"&&(n("Server address already in use: %s:%d.",r,i),i+=1,i<=v)){n("Attempting to listen on %s:%d.",r,i),a.listen(i,r);return}throw s}function P(){var s=a.address();n("HTTP server initialized. Server is listening for requests on %s:%d.",s.address,s.port),p(null,a)}}}y.exports=F
5
+ });var I=O();module.exports=I;
6
+ /** @license Apache-2.0 */
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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": "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",
6
+ "names": ["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
+ }
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /**
22
22
  * Interface defining function options.
package/lib/index.js CHANGED
@@ -43,9 +43,9 @@
43
43
 
44
44
  // MODULES //
45
45
 
46
- var httpServer = require( './server.js' );
46
+ var main = require( './main.js' );
47
47
 
48
48
 
49
49
  // EXPORTS //
50
50
 
51
- module.exports = httpServer;
51
+ module.exports = main;
@@ -23,6 +23,7 @@
23
23
  var http = require( 'http' );
24
24
  var logger = require( 'debug' );
25
25
  var isFunction = require( '@stdlib/assert-is-function' );
26
+ var format = require( '@stdlib/string-format' );
26
27
  var validate = require( './validate.js' );
27
28
  var DEFAULTS = require( './defaults.json' );
28
29
 
@@ -92,7 +93,7 @@ function httpServer() {
92
93
  options = arguments[ 0 ];
93
94
  requestListener = arguments[ 1 ];
94
95
  if ( !isFunction( requestListener ) ) {
95
- throw new TypeError( 'invalid argument. Request listener must be a function. Value: `' + requestListener + '`.' );
96
+ throw new TypeError( format( 'invalid argument. Request listener must be a function. Value: `%s`.', requestListener ) );
96
97
  }
97
98
  err = validate( opts, options );
98
99
  }
@@ -146,7 +147,7 @@ function httpServer() {
146
147
  function createServer( done ) {
147
148
  var server;
148
149
  if ( !isFunction( done ) ) {
149
- throw new TypeError( 'invalid argument. Callback must be a function. Value: `' + done + '`.' );
150
+ throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', done ) );
150
151
  }
151
152
  if ( requestListener ) {
152
153
  server = http.createServer( requestListener );
package/lib/validate.js CHANGED
@@ -24,6 +24,7 @@ var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).is
24
24
  var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
25
25
  var isObject = require( '@stdlib/assert-is-plain-object' );
26
26
  var hasOwnProp = require( '@stdlib/assert-has-own-property' );
27
+ var format = require( '@stdlib/string-format' );
27
28
 
28
29
 
29
30
  // MAIN //
@@ -53,30 +54,30 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' );
53
54
  */
54
55
  function validate( opts, options ) {
55
56
  if ( !isObject( options ) ) {
56
- return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' );
57
+ return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
57
58
  }
58
59
  if ( hasOwnProp( options, 'port' ) ) {
59
60
  opts.port = options.port;
60
61
  if ( !isNonNegativeInteger( opts.port ) ) {
61
- return new TypeError( 'invalid option. `port` must be a nonnegative integer. Option: `' + opts.port + '`.' );
62
+ return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'port', opts.port ) );
62
63
  }
63
64
  }
64
65
  if ( hasOwnProp( options, 'maxport' ) ) {
65
66
  opts.maxport = options.maxport;
66
67
  if ( !isNonNegativeInteger( opts.maxport ) ) {
67
- return new TypeError( 'invalid option. `maxport` option must be a nonnegative integer. Option: `' + opts.maxport + '`.' );
68
+ return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'maxport', opts.maxport ) );
68
69
  }
69
70
  }
70
71
  if ( hasOwnProp( options, 'hostname' ) ) {
71
72
  opts.hostname = options.hostname;
72
73
  if ( !isString( opts.hostname ) ) {
73
- return new TypeError( 'invalid option. `hostname` option must be a primitive string. Option: `' + opts.hostname + '`.' );
74
+ return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'hostname', opts.hostname ) );
74
75
  }
75
76
  }
76
77
  if ( hasOwnProp( options, 'address' ) ) {
77
78
  opts.address = options.address;
78
79
  if ( !isString( opts.address ) ) {
79
- return new TypeError( 'invalid option. `address` option must be a primitive string. Option: `' + opts.address + '`.' );
80
+ return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'address', opts.address ) );
80
81
  }
81
82
  }
82
83
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/net-http-server",
3
- "version": "0.0.7",
3
+ "version": "0.1.0",
4
4
  "description": "HTTP server.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -35,19 +35,21 @@
35
35
  "url": "https://github.com/stdlib-js/stdlib/issues"
36
36
  },
37
37
  "dependencies": {
38
- "@stdlib/assert-has-own-property": "^0.0.x",
39
- "@stdlib/assert-is-function": "^0.0.x",
40
- "@stdlib/assert-is-nonnegative-integer": "^0.0.x",
41
- "@stdlib/assert-is-plain-object": "^0.0.x",
42
- "@stdlib/assert-is-string": "^0.0.x",
43
- "debug": "^2.6.9"
38
+ "@stdlib/assert-has-own-property": "^0.1.0",
39
+ "@stdlib/assert-is-function": "^0.1.0",
40
+ "@stdlib/assert-is-nonnegative-integer": "^0.1.0",
41
+ "@stdlib/assert-is-plain-object": "^0.1.0",
42
+ "@stdlib/assert-is-string": "^0.1.0",
43
+ "@stdlib/string-format": "^0.1.0",
44
+ "debug": "^2.6.9",
45
+ "@stdlib/error-tools-fmtprodmsg": "^0.1.0"
44
46
  },
45
47
  "devDependencies": {
46
- "@stdlib/utils-keys": "^0.0.x",
47
- "@stdlib/utils-noop": "^0.0.x",
48
+ "@stdlib/utils-keys": "^0.0.7",
49
+ "@stdlib/utils-noop": "^0.1.0",
48
50
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
49
51
  "istanbul": "^0.4.1",
50
- "tap-spec": "5.x.x"
52
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
51
53
  },
52
54
  "engines": {
53
55
  "node": ">=0.10.0",
@@ -74,7 +76,7 @@
74
76
  "create"
75
77
  ],
76
78
  "funding": {
77
- "type": "patreon",
78
- "url": "https://www.patreon.com/athan"
79
+ "type": "opencollective",
80
+ "url": "https://opencollective.com/stdlib"
79
81
  }
80
82
  }
package/docs/repl.txt DELETED
@@ -1,72 +0,0 @@
1
-
2
- {{alias}}( [options,] [requestListener] )
3
- Returns a function to create an HTTP server.
4
-
5
- Parameters
6
- ----------
7
- options: Object (optional)
8
- Options.
9
-
10
- options.port: integer (optional)
11
- Server port. Default: `0` (i.e., randomly assigned).
12
-
13
- options.maxport: integer (optional)
14
- Max server port when port hunting. Default: `maxport = port`.
15
-
16
- options.hostname: string (optional)
17
- Server hostname.
18
-
19
- options.address: string (optional)
20
- Server address. Default: `'127.0.0.1'`.
21
-
22
- requestListener: Function (optional)
23
- Request callback.
24
-
25
- Returns
26
- -------
27
- createServer: Function
28
- Function to create an HTTP server.
29
-
30
- Examples
31
- --------
32
- // Basic usage:
33
- > var createServer = {{alias}}()
34
- <Function>
35
-
36
- // Provide a request callback:
37
- > function onRequest( request, response ) {
38
- ... console.log( request.url );
39
- ... response.end( 'OK' );
40
- ... };
41
- > createServer = {{alias}}( onRequest )
42
- <Function>
43
-
44
- // Specify a specific port:
45
- > var opts = { 'port': 7331 };
46
- > createServer = {{alias}}( opts )
47
- <Function>
48
-
49
-
50
- createServer( done )
51
- Creates an HTTP server.
52
-
53
- Parameters
54
- ----------
55
- done: Function
56
- Callback to invoke after creating a server.
57
-
58
- Examples
59
- --------
60
- > function done( error, server ) {
61
- ... if ( error ) {
62
- ... throw error;
63
- ... }
64
- ... console.log( 'Success!' );
65
- ... server.close();
66
- ... };
67
- > var createServer = {{alias}}();
68
- > createServer( done );
69
-
70
- See Also
71
- --------
72
-
@@ -1,149 +0,0 @@
1
- /*
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2021 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- /* tslint:disable:no-unsafe-any */
20
-
21
- import httpServer = require( './index' );
22
-
23
- /**
24
- * Request callback.
25
- *
26
- * @param request - request object
27
- * @param response - response object
28
- */
29
- function requestListener( request: any, response: any ) {
30
- if ( !request ) {
31
- throw Error( 'Request is missing...' );
32
- }
33
- response.end( 'OK' );
34
- }
35
-
36
- /**
37
- * Callback invoked after creating a server.
38
- *
39
- * @param error - error object or null
40
- * @param server - server object
41
- */
42
- function done( error: Error | null, server: any ) {
43
- if ( error ) {
44
- throw error;
45
- }
46
- server.close();
47
- }
48
-
49
-
50
- // TESTS //
51
-
52
- // The function returns a function to create a server...
53
- {
54
- httpServer(); // $ExpectType createServer
55
- httpServer( requestListener ); // $ExpectType createServer
56
- httpServer( { 'port': 80 }, requestListener ); // $ExpectType createServer
57
-
58
- const createServer = httpServer(); // $ExpectType createServer
59
- createServer( done ); // $ExpectType void
60
- }
61
-
62
- // The compiler throws an error if the function is provided a first argument which is not an options object or callback function...
63
- {
64
- httpServer( 'abc' ); // $ExpectError
65
- httpServer( true ); // $ExpectError
66
- httpServer( false ); // $ExpectError
67
- httpServer( 5 ); // $ExpectError
68
- httpServer( [] ); // $ExpectError
69
- }
70
-
71
- // The compiler throws an error if the function is provided a second argument which is not a callback function...
72
- {
73
- httpServer( {}, false ); // $ExpectError
74
- httpServer( {}, true ); // $ExpectError
75
- httpServer( {}, 123 ); // $ExpectError
76
- httpServer( {}, null ); // $ExpectError
77
- httpServer( {}, 'abc' ); // $ExpectError
78
- httpServer( {}, [] ); // $ExpectError
79
- httpServer( {}, {} ); // $ExpectError
80
- }
81
-
82
- // The compiler throws an error if the function is provided a `port` option which is not a number...
83
- {
84
- httpServer( { 'port': 'abc' }, requestListener ); // $ExpectError
85
- httpServer( { 'port': true }, requestListener ); // $ExpectError
86
- httpServer( { 'port': false }, requestListener ); // $ExpectError
87
- httpServer( { 'port': null }, requestListener ); // $ExpectError
88
- httpServer( { 'port': [] }, requestListener ); // $ExpectError
89
- httpServer( { 'port': {} }, requestListener ); // $ExpectError
90
- httpServer( { 'port': ( x: number ): number => x }, requestListener ); // $ExpectError
91
- }
92
-
93
- // The compiler throws an error if the function is provided a `maxPort` option which is not a number...
94
- {
95
- httpServer( { 'maxPort': 'abc' }, requestListener ); // $ExpectError
96
- httpServer( { 'maxPort': true }, requestListener ); // $ExpectError
97
- httpServer( { 'maxPort': false }, requestListener ); // $ExpectError
98
- httpServer( { 'maxPort': null }, requestListener ); // $ExpectError
99
- httpServer( { 'maxPort': [] }, requestListener ); // $ExpectError
100
- httpServer( { 'maxPort': {} }, requestListener ); // $ExpectError
101
- httpServer( { 'maxPort': ( x: number ): number => x }, requestListener ); // $ExpectError
102
- }
103
-
104
- // The compiler throws an error if the function is provided a `hostname` option which is not a string...
105
- {
106
- httpServer( { 'hostname': 123 }, requestListener ); // $ExpectError
107
- httpServer( { 'hostname': true }, requestListener ); // $ExpectError
108
- httpServer( { 'hostname': false }, requestListener ); // $ExpectError
109
- httpServer( { 'hostname': null }, requestListener ); // $ExpectError
110
- httpServer( { 'hostname': [] }, requestListener ); // $ExpectError
111
- httpServer( { 'hostname': {} }, requestListener ); // $ExpectError
112
- httpServer( { 'hostname': ( x: number ): number => x }, requestListener ); // $ExpectError
113
- }
114
-
115
- // The compiler throws an error if the function is provided an `address` option which is not a string...
116
- {
117
- httpServer( { 'address': 123 }, requestListener ); // $ExpectError
118
- httpServer( { 'address': true }, requestListener ); // $ExpectError
119
- httpServer( { 'address': false }, requestListener ); // $ExpectError
120
- httpServer( { 'address': null }, requestListener ); // $ExpectError
121
- httpServer( { 'address': [] }, requestListener ); // $ExpectError
122
- httpServer( { 'address': {} }, requestListener ); // $ExpectError
123
- httpServer( { 'address': ( x: number ): number => x }, requestListener ); // $ExpectError
124
- }
125
-
126
- // The compiler throws an error if the function is provided an invalid number of arguments...
127
- {
128
- httpServer( {}, requestListener, {} ); // $ExpectError
129
- }
130
-
131
- // The compiler throws an error if the returned function is invoked with an argument that is not a callback function...
132
- {
133
- const createServer = httpServer();
134
- createServer( 'abc' ); // $ExpectError
135
- createServer( 123 ); // $ExpectError
136
- createServer( true ); // $ExpectError
137
- createServer( false ); // $ExpectError
138
- createServer( null ); // $ExpectError
139
- createServer( [] ); // $ExpectError
140
- createServer( {} ); // $ExpectError
141
- createServer( ( x: number ): number => x ); // $ExpectError
142
- }
143
-
144
- // The compiler throws an error if the returned function is invoked with an invalid number of arguments...
145
- {
146
- const createServer = httpServer();
147
- createServer(); // $ExpectError
148
- createServer( done, {} ); // $ExpectError
149
- }