@imenam/self-register-proxy 1.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { escapeHtml } = require('../services/proxyRouter');
4
+
5
+ const templatePath = path.join(__dirname, 'terminal.html');
6
+ let templateCache = null;
7
+
8
+ function loadTemplate() {
9
+ if (!templateCache) {
10
+ templateCache = fs.readFileSync(templatePath, 'utf-8');
11
+ }
12
+ return templateCache;
13
+ }
14
+
15
+ /**
16
+ * Page du terminal en ligne (xterm.js + WebSocket)
17
+ * @param {string} proxyName
18
+ * @param {string} terminalCommand
19
+ */
20
+ function renderTerminal(proxyName, terminalCommand) {
21
+ const commandHtml = terminalCommand
22
+ ? '<span class="terminal-command">' + escapeHtml(terminalCommand) + '</span>'
23
+ : '';
24
+
25
+ return loadTemplate()
26
+ .replace('{{PROXY_NAME}}', escapeHtml(proxyName))
27
+ .replace('{{TERMINAL_COMMAND}}', commandHtml);
28
+ }
29
+
30
+ module.exports = { renderTerminal };