add ingress controller
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import fs from "fs"
|
||||
import os from "os"
|
||||
import path from "path"
|
||||
import express, { Express, NextFunction, Request, Response } from "express"
|
||||
import express, { Express } from "express"
|
||||
import dotenv from "dotenv"
|
||||
import { createServer } from "http"
|
||||
import { Server } from "socket.io"
|
||||
@ -9,7 +9,6 @@ import { Server } from "socket.io"
|
||||
import { z } from "zod"
|
||||
import { User } from "./types"
|
||||
import { createFile, getSandboxFiles, renameFile, saveFile } from "./utils"
|
||||
import { Pty } from "./terminal"
|
||||
import { IDisposable, IPty, spawn } from "node-pty"
|
||||
|
||||
dotenv.config()
|
||||
|
@ -1,52 +0,0 @@
|
||||
import { spawn, IPty } from "node-pty"
|
||||
import { Socket } from "socket.io"
|
||||
import os from "os"
|
||||
|
||||
export class Pty {
|
||||
socket: Socket
|
||||
ptyProcess: IPty
|
||||
id: string
|
||||
|
||||
constructor(socket: Socket, id: string, cwd: string) {
|
||||
this.socket = socket
|
||||
this.id = id
|
||||
|
||||
this.ptyProcess = spawn(
|
||||
os.platform() === "win32" ? "cmd.exe" : "bash",
|
||||
[],
|
||||
{
|
||||
name: "xterm",
|
||||
cols: 100,
|
||||
cwd: cwd,
|
||||
}
|
||||
)
|
||||
|
||||
this.ptyProcess.onData((data) => {
|
||||
console.log("onData", data)
|
||||
this.send(data)
|
||||
})
|
||||
|
||||
// this.write("hello world")
|
||||
}
|
||||
|
||||
write(data: string) {
|
||||
console.log("writing data", data)
|
||||
|
||||
this.ptyProcess.write(data)
|
||||
}
|
||||
|
||||
send(data: string) {
|
||||
this.socket.emit("terminalResponse", {
|
||||
data: Buffer.from(data, "utf-8"),
|
||||
})
|
||||
}
|
||||
|
||||
// kill() {
|
||||
// console.log("killing terminal")
|
||||
|
||||
// if (os.platform() !== "win32") {
|
||||
// this.ptyProcess.kill()
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
}
|
Reference in New Issue
Block a user