Spaces:
Sleeping
Sleeping
File size: 2,153 Bytes
cfbbc1a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpAdapterHost = void 0;
const rxjs_1 = require("rxjs");
/**
* Defines the `HttpAdapterHost` object.
*
* `HttpAdapterHost` wraps the underlying
* platform-specific `HttpAdapter`. The `HttpAdapter` is a wrapper around the underlying
* native HTTP server library (e.g., Express). The `HttpAdapterHost` object
* provides methods to `get` and `set` the underlying HttpAdapter.
*
* @see [Http adapter](https://docs.nestjs.com/faq/http-adapter)
*
* @publicApi
*/
class HttpAdapterHost {
constructor() {
this._listen$ = new rxjs_1.Subject();
this._init$ = new rxjs_1.ReplaySubject();
this.isListening = false;
}
/**
* Accessor for the underlying `HttpAdapter`
*
* @param httpAdapter reference to the `HttpAdapter` to be set
*/
set httpAdapter(httpAdapter) {
this._httpAdapter = httpAdapter;
this._init$.next();
this._init$.complete();
}
/**
* Accessor for the underlying `HttpAdapter`
*
* @example
* `const httpAdapter = adapterHost.httpAdapter;`
*/
get httpAdapter() {
return this._httpAdapter;
}
/**
* Observable that allows to subscribe to the `listen` event.
* This event is emitted when the HTTP application is listening for incoming requests.
*/
get listen$() {
return this._listen$.asObservable();
}
/**
* Observable that allows to subscribe to the `init` event.
* This event is emitted when the HTTP application is initialized.
*/
get init$() {
return this._init$.asObservable();
}
/**
* Sets the listening state of the application.
*/
set listening(listening) {
this.isListening = listening;
if (listening) {
this._listen$.next();
this._listen$.complete();
}
}
/**
* Returns a boolean indicating whether the application is listening for incoming requests.
*/
get listening() {
return this.isListening;
}
}
exports.HttpAdapterHost = HttpAdapterHost;
|