1.6 Bootstrap server
We bootstrap module in separate file because we want to divide logic from starting http server and Application module.
Other benefit is that we can run fake http server and we can use it for testing purposes if we want to invoke server side request.
We always use httpServer function on our root Application module once in our project to startup http server, but if we really want we can start separate module on separate port and application will work as expected as long as we keep divided routing.
As you can see this feature gives us a lot flexibility for example if we see that our application is becoming to big to maintain by one team or to complex we can simply divide it into multiple applications and start them as separate processes.
import {Application} from "./application";
import {httpServer} from "typeix";
/**
* Bootstraps server
*
* @function
* @name httpServer
*
* @description
* Creates server instance on port 9000
* We always use separate bootstrap file to bootstrap application because of testing or server side fakeHttp feature.
* We will be able to simulate server side request with fakeHttp
*/
httpServer(Application, { port: 9000 });