* Start this REST API's HTTP/HTTPS server.
()
| 973 | * Start this REST API's HTTP/HTTPS server. |
| 974 | */ |
| 975 | async start(): Promise<void> { |
| 976 | // Set up the Express app if not done yet |
| 977 | this._setupRequestHandlerIfNeeded(); |
| 978 | // Setup the HTTP handler so that we can verify the configuration |
| 979 | // of API spec, controllers and routes at startup time. |
| 980 | this._setupHandlerIfNeeded(); |
| 981 | |
| 982 | const port = await this.get(RestBindings.PORT); |
| 983 | const host = await this.get(RestBindings.HOST); |
| 984 | const path = await this.get(RestBindings.PATH); |
| 985 | const protocol = await this.get(RestBindings.PROTOCOL); |
| 986 | const httpsOptions = await this.get(RestBindings.HTTPS_OPTIONS); |
| 987 | |
| 988 | if (this.config.listenOnStart === false) { |
| 989 | debug( |
| 990 | 'RestServer is not listening as listenOnStart flag is set to false.', |
| 991 | ); |
| 992 | return; |
| 993 | } |
| 994 | |
| 995 | const serverOptions = {...httpsOptions, port, host, protocol, path}; |
| 996 | this._httpServer = new HttpServer(this.requestHandler, serverOptions); |
| 997 | |
| 998 | await this._httpServer.start(); |
| 999 | |
| 1000 | this.bind(RestBindings.PORT).to(this._httpServer.port); |
| 1001 | this.bind(RestBindings.HOST).to(this._httpServer.host); |
| 1002 | this.bind(RestBindings.URL).to(this._httpServer.url); |
| 1003 | debug('RestServer listening at %s', this._httpServer.url); |
| 1004 | } |
| 1005 | |
| 1006 | /** |
| 1007 | * Stop this REST API's HTTP/HTTPS server. |
nothing calls this directly
no test coverage detected