test( "given that CUBEJS_ENABLE_TLS is true, " + "should create an https server that listens to the TLS_PORT", async () => { // arrange process.env.CUBEJS_ENABLE_TLS = "true"; const server = new CubeServer(); // act await server.listen(); // assert expect(https.createServer).toHaveBeenCalledTimes(1); expect(https.__mockServer.listen).toHaveBeenCalledTimes(1); expect(https.__mockServer.listen.mock.calls[0][0]).toBe(4433); } );
test("given an option object, should pass the options object to the created server instance", async () => { // arrange process.env.CUBEJS_ENABLE_TLS = "true"; let options = { key: true, cert: true }; let server = new CubeServer(); // act await server.listen(options); // assert expect(https.createServer.mock.calls[0][0]).toBe(options); // arrange process.env.CUBEJS_ENABLE_TLS = "false"; options = { key: true, cert: true }; server = new CubeServer(); // act await server.listen(options); // assert expect(http.createServer.mock.calls[1][0]).toBe(options); });
this.options.https.key = fs.readFileSync(this.options.key); this.options.https.cert = fs.readFileSync(this.options.cert); this._webServer = https.createServer(this.options.https, this._requestListener); } else if (this.options.pfx) { debug('HTTPS WebHook enabled (by pfx)'); this.options.https.pfx = fs.readFileSync(this.options.pfx); this._webServer = https.createServer(this.options.https, this._requestListener); } else if (Object.keys(this.options.https).length) { debug('HTTPS WebHook enabled by (https)'); this._webServer = https.createServer(this.options.https, this._requestListener); } else { debug('HTTP WebHook enabled'); this._webServer = http.createServer(this._requestListener);
this.redirector = http.createServer((req, res) => { res.writeHead(301, { Location: `https://${req.headers.host.split(':')[0]}:${TLS_PORT}${req.url}` httpOrHttps.createServer(options, app) : httpOrHttps.createServer(app);
https.createServer(httpsOptions, (req, res) => { // Send "Hello World" to every request res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World'); })
https.createServer(options, (req, res) => { console.log(req.url); res.writeHead(200); res.end('hello world\n'); }).listen(6789);
getSocket (secure) { if (!secure) { return http.createServer() } assert(Buffer.isBuffer(secure.key), 'conf.secure.key must be a Buffer') assert(Buffer.isBuffer(secure.cert), 'conf.secure.cert must be a Buffer') assert(Buffer.isBuffer(secure.ca), 'conf.secure.ca must be a Buffer') return https.createServer(secure) }
createServer({ key: readFileSync("../../cert/" + env + ".pem", "utf8"), cert: readFileSync("../../cert/" + env + ".crt", "utf8") }, app).listen(config.port_ssl, function(err){ if(err) throw err; console.info("Server@" + process.pid + " listening on https://localhost" + (config.port_ssl !== 443 ? ":" + config.port_ssl : "")); });
https.createServer(options, app).listen(port, error => { if (error) { logger.error(error); return process.exit(1); } else { logger.info('Listening on port: %s', port); sendToParent('backend: started'); } });
https .createServer(options, function(req, res) { res.head(200); res.end('hello world'); }) .listen(9999);
https.createServer(options, ts_app).listen({port: usetsagentport, agent: false}, function () { console.log('ts_missing agent server (' + ip.address() + ') running at ' + usetsagentport + ' port'); // Searching TS with missingDetect. if it is TRUE, restart mdt init_TS(function (rsc) { console.log('init_TS - ' + rsc); }); });
https.createServer({ key : fs.readFileSync('path/to/keys/agent2-key.pem'), cert: fs.readFileSync('path/to/keys/agent2-cert.pem') }, function (req, res) { nodeSession.startSession(req, res, function () { // server handler goes here // req.session available }) } ).listen(8000)
function createSecureServer(app) { // Server the app over https return https.createServer({ key: fs.readFileSync('./test/certs/server.key'), cert: fs.readFileSync('./test/certs/server.crt'), ca: fs.readFileSync('./test/certs/ca.crt'), requestCert: true, rejectUnauthorized: false }, app).listen('8443'); }
// // app.use(express.static(__dirname + '/img')); https.createServer(https_options, app).listen(443, function(){ console.log("Momo Server is Running"); });
https.createServer(options, (req, res) => { console.log(req.url); res.writeHead(200); res.end('hello world\n'); }).listen(6789);