UNPKG

@zohodesk/client_build_tool

Version:

A CLI tool to build web applications and client libraries

41 lines (33 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addHttp2Server = addHttp2Server; var _utils = require("../../../src/utils"); var _httpsOptions = require("../../../src/servers/httpsOptions"); function addHttp2Server(http2Port, host, domain, contextURL) { const isCompatableHttp2 = Number(process.version.slice(1).split('.')[0]) >= 8; if (isCompatableHttp2) { const http2 = require('http2'); const http2Server = http2.createSecureServer(_httpsOptions.httpsOptions); // eslint-disable-next-line no-unused-vars http2Server.on('stream', (stream, headers) => { stream.respond({ 'content-type': 'text/html', ':status': 200 }); stream.end('<h1>Hello World! <br>Working with http2</h1>'); }); http2Server.listen(http2Port, err => { if (err) { throw err; } (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({ host, domain, port: http2Port }, 'htt' + 'ps')}${contextURL}/`, 'http2 server'); }); } else { (0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2'); } }