mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
30 lines
890 B
TypeScript
30 lines
890 B
TypeScript
import { start } from "$fresh/server.ts";
|
|
import { load_settings } from "./config.ts";
|
|
import manifest from "./fresh.gen.ts";
|
|
import { TaskManager } from "./task_manager.ts";
|
|
import twindPlugin from "$fresh/plugins/twind.ts";
|
|
import twindConfig from "./twind.config.ts";
|
|
|
|
let task_manager: TaskManager | undefined = undefined;
|
|
let cfg_path: string | undefined = undefined;
|
|
|
|
export function get_task_manager() {
|
|
if (!task_manager) throw Error("task manager undefined.");
|
|
return task_manager;
|
|
}
|
|
|
|
export function get_cfg_path() {
|
|
if (!cfg_path) throw Error("cfg_path undefined.");
|
|
return cfg_path;
|
|
}
|
|
|
|
export async function startServer(path: string) {
|
|
cfg_path = path;
|
|
const cfg = await load_settings(path);
|
|
task_manager = new TaskManager(cfg);
|
|
return start(manifest, {
|
|
signal: task_manager.aborts,
|
|
plugins: [twindPlugin(twindConfig)],
|
|
});
|
|
}
|