From 25b97dcada3e60173b4656cc7a500a88538b8457 Mon Sep 17 00:00:00 2001 From: Pranav C Balan Date: Wed, 2 Jun 2021 20:20:52 +0530 Subject: [PATCH] refactor: remove unnecessary dependencies Removed unnecessary dependencies from xc-plib-gui related #220 Signed-off-by: Pranav C Balan --- packages/nc-lib-gui/lib/XcLibGui.js | 67 ----------------------------- 1 file changed, 67 deletions(-) diff --git a/packages/nc-lib-gui/lib/XcLibGui.js b/packages/nc-lib-gui/lib/XcLibGui.js index 8b730ecef3..c272353351 100644 --- a/packages/nc-lib-gui/lib/XcLibGui.js +++ b/packages/nc-lib-gui/lib/XcLibGui.js @@ -1,97 +1,30 @@ const express = require('express'); -const bodyParser = require("body-parser"); const path = require('path'); -const Emittery = require('emittery'); -const EVENT_NAME = 'dbOps'; class XcLibGui { constructor(config) { this.config = config; - this.emitter = new Emittery(); - process.env.TS_ENABLED = config.language === 'ts'; - this.io = require('socket.io')(); - this.io.listen(8081); } expressMiddleware() { const router = express.Router(); - - router.use(bodyParser.json({ - limit: process.env.NC_REQUEST_BODY_SIZE || 1024 * 1024 - })); - - router.use('/', express.static(path.join(__dirname, 'dist'))); - - - // const os = require('os'); - // - // try { - // const pty = require('node-pty-prebuilt-multiarch'); - // - // this.io.on('connection', client => { - // - // const ptyProc = pty.spawn(os.platform() === 'win32' ? 'powershell.exe' : process.env.SHELL || '/bin/sh', [], { - // // cols: term.cols, - // rows: 70,//term.rows, - // cwd: process.cwd() || process.env.HOME, - // env: process.env - // }); - // - // client.on('req', data => { - // ptyProc.write(data); - // }); - // - // ptyProc.onData(data => { - // client.emit('res', data); - // }); - // - // client.on('disconnect', () => { - // console.log('Disconnected'); - // ptyProc.kill(); - // }); - // - // }); - // } catch (e) { - // - // } - - return router; } addListener(handler) { - this.emitter.on(EVENT_NAME, handler); } destroy() { - try { - if (this.emitter) { - this.emitter.clearListeners(EVENT_NAME); - } - - if (this.io) { - this.io.close(() => { - console.log('Server connection closed'); - }); - this.io = null; - } - } catch (e) { - console.log('xc-lib-gui : destroy error', e) - } } reInitialize(config) { this.config = config; - this.io = require('socket.io')(); - this.io.listen(8081); } - - } module.exports = XcLibGui;