项目文件夹

文件
caorushizi 8e8e71bd6b feat: replace Node.js server with Go Core direct connection
- Remove old Koa/Socket.IO server, replace with minimal ServiceRunner launcher
- UI now connects directly to Go Core via SDK (HTTP + SSE), no middleware
- Add GoEventBridge for SSE events and progress polling
- Add Dockerfile and docker-compose for single-container deployment
- Fix web mode adapter Proxy ownKeys for proper method enumeration
- Fix auth flow: setupAuth now sets apiKey, App.tsx passes stored apiKey
- Add error handling in download-form for getVideoFolders
- Remove conversion.controller import (file was deleted)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-31 17:30:44 +08:00

75 行
1.7 KiB
TypeScript

import { type ChildProcessWithoutNullStreams, spawn } from "node:child_process";
import path, { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "tsdown";
import dotenvFlow from "dotenv-flow";
const isDev = process.env.NODE_ENV === "development";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const projectRoot = path.resolve(__dirname, "../..");
const env = dotenvFlow.config({
path: projectRoot,
});
class NodeApp {
process: ChildProcessWithoutNullStreams | null = null;
start() {
const args = [path.resolve(__dirname, "./build/index.js")];
this.process = spawn("node", args, {
stdio: ["ignore", "pipe", "pipe"],
env: { ...process.env },
});
this.process.stdout.on("data", (data) => {
process.stdout.write(String(data));
});
this.process.stderr.on("data", (data) => {
process.stderr.write(String(data));
});
}
restart() {
this.kill();
this.start();
}
kill() {
if (this.process?.pid) {
if (process.platform === "win32") {
process.kill(this.process.pid);
} else {
spawn("kill", ["-9", String(this.process.pid)]);
}
this.process = null;
}
}
}
const app = new NodeApp();
export default defineConfig({
outDir: "build",
shims: true,
external: ["@mediago/core", "@mediago/deps"],
noExternal: [/.*/],
define: {
"process.env.NODE_ENV": JSON.stringify(
process.env.NODE_ENV || "production",
),
"process.env.APP_TARGET": JSON.stringify("server"),
},
env: { ...env.parsed },
hooks: {
"build:done": () => {
if (isDev) {
app.restart();
}
},
},
});