constructor(config: any) { super(config); this.connection.on('parameterStatus', msg => { // See the following question: // https://stackoverflow.com/questions/58725659/get-the-postgresql-server-version-from-connection if (msg.parameterName === 'server_version') { this.version = msg.parameterValue; } }); this.connection.stream.on('something', () => { }); // any event handlers are allowed: this.on('whatever', (whatever1: any, whatever2: any) => { }); this.query('test', [1, 2]).then(); }
stdin.addListener("data", function(input) { fullInput += input.toString() + " "; if(input.toString().indexOf(";") !== -1) { db.all(fullInput, function(err, res) { console.log(err); console.log("results:" + JSON.stringify(res)); }); fullInput = ""; } });
//process command line input //and start the server const processCmdInput = () => { const stdin = process.openStdin(); console.log("\n\nAvailable interfaces:") Object.keys(interfaces).forEach((interface,index) => { console.log(`${interface}`) }) console.log("Type your interface down like en0 and press enter:") stdin.addListener("data",(val) => { const selectedOption = capitalize(val.toString().trim()); console.log(`you entered: ${selectedOption}`); let selectedInterface = interfaces[selectedOption] && interfaces[selectedOption].find((interface) => { return interface.family === 'IPv4' }); if(selectedInterface) { console.log("\n\nQR Code generated : Please scan and download the file") qrcode.generate(`http://${selectedInterface.address}:3000/download`, { small: true }); app.listen(3000, selectedInterface.address) stdin.removeAllListeners('data') //no need to listen console prompt } else { console.error("Can't start server on the given interface, please try other interface") } }); }