@travetto/web-node
v6.0.3
Published
Node provider for the travetto web module.
Readme
Node Web Server
Node provider for the travetto web module.
Install: @travetto/web-node
npm install @travetto/web-node
# or
yarn add @travetto/web-nodeThe module is an http adapter for the Web API module. This module provides will run an http or https server using Node primitives.
Code: Node Web Server
export class NodeWebServer implements WebHttpServer {
@Inject()
serverConfig: WebHttpConfig;
@Inject()
router: StandardWebRouter;
@Inject()
configService: ConfigurationService;
async serve(): Promise<WebServerHandle> {
const handle = await WebHttpUtil.startHttpServer({ ...this.serverConfig, dispatcher: this.router, });
console.log('Initialized', await this.configService.initBanner());
console.log('Listening', { port: this.serverConfig.port });
return handle;
}
}In the handler code, you can see that the main work is:
- Converting the node primitive request to a WebRequest
- Dispatching the request through the framework
- Receiving the WebResponse and sending that back over the primitive response.
