* Starts the HTTP or HTTPS server * @returns {Tenso} The Tenso instance for method chaining
()
| 372 | * @returns {Tenso} The Tenso instance for method chaining |
| 373 | */ |
| 374 | start () { |
| 375 | if (this.server === null) { |
| 376 | if (this.ssl.cert === null && this.ssl.pfx === null && this.ssl.key === null) { |
| 377 | this.server = http.createServer(this.route).listen(this.port, this.host); |
| 378 | } else { |
| 379 | this.server = https.createServer({ |
| 380 | cert: this.ssl.cert ? readFileSync(this.ssl.cert) : void INT_0, |
| 381 | pfx: this.ssl.pfx ? readFileSync(this.ssl.pfx) : void INT_0, |
| 382 | key: this.ssl.key ? readFileSync(this.ssl.key) : void INT_0, |
| 383 | port: this.port, |
| 384 | host: this.host |
| 385 | }, this.route).listen(this.port, this.host); |
| 386 | } |
| 387 | |
| 388 | this.log(`Started server on ${this.host}:${this.port}`); |
| 389 | } |
| 390 | |
| 391 | return this; |
| 392 | } |
| 393 | |
| 394 | /** |
| 395 | * Stops the server |
no test coverage detected