chore: fix lint warnings and formatting
parent
7b1832bd24
commit
c3f955d3f1
|
|
@ -348,6 +348,7 @@ enum CommandResolver {
|
||||||
let quotedArgs = ([subcommand] + extraArgs).map(self.shellQuote).joined(separator: " ")
|
let quotedArgs = ([subcommand] + extraArgs).map(self.shellQuote).joined(separator: " ")
|
||||||
let scriptBody = """
|
let scriptBody = """
|
||||||
PATH=\(exportedPath);
|
PATH=\(exportedPath);
|
||||||
|
CLI="";
|
||||||
\(prjVar)
|
\(prjVar)
|
||||||
if command -v clawdis >/dev/null 2>&1; then
|
if command -v clawdis >/dev/null 2>&1; then
|
||||||
\(cdPrefix)clawdis \(quotedArgs);
|
\(cdPrefix)clawdis \(quotedArgs);
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,10 @@ const readUsageFromSessionLog = (
|
||||||
if (!line.trim()) continue;
|
if (!line.trim()) continue;
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(line) as {
|
const parsed = JSON.parse(line) as {
|
||||||
message?: { usage?: { input?: number; output?: number; total?: number }; model?: string };
|
message?: {
|
||||||
|
usage?: { input?: number; output?: number; total?: number };
|
||||||
|
model?: string;
|
||||||
|
};
|
||||||
usage?: { input?: number; output?: number; total?: number };
|
usage?: { input?: number; output?: number; total?: number };
|
||||||
model?: string;
|
model?: string;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,14 @@ describe("cli program", () => {
|
||||||
monitorWebProvider.mockResolvedValue(undefined);
|
monitorWebProvider.mockResolvedValue(undefined);
|
||||||
const program = buildProgram();
|
const program = buildProgram();
|
||||||
await program.parseAsync(
|
await program.parseAsync(
|
||||||
["relay", "--web-heartbeat", "90", "--heartbeat-now", "--provider", "web"],
|
[
|
||||||
|
"relay",
|
||||||
|
"--web-heartbeat",
|
||||||
|
"90",
|
||||||
|
"--heartbeat-now",
|
||||||
|
"--provider",
|
||||||
|
"web",
|
||||||
|
],
|
||||||
{
|
{
|
||||||
from: "user",
|
from: "user",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,16 @@ import {
|
||||||
setHeartbeatsEnabled,
|
setHeartbeatsEnabled,
|
||||||
type WebMonitorTuning,
|
type WebMonitorTuning,
|
||||||
} from "../provider-web.js";
|
} from "../provider-web.js";
|
||||||
import {
|
|
||||||
startWebChatServer,
|
|
||||||
getWebChatServer,
|
|
||||||
ensureWebChatServerFromConfig,
|
|
||||||
} from "../webchat/server.js";
|
|
||||||
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
||||||
import { VERSION } from "../version.js";
|
import { VERSION } from "../version.js";
|
||||||
import {
|
import {
|
||||||
resolveHeartbeatSeconds,
|
resolveHeartbeatSeconds,
|
||||||
resolveReconnectPolicy,
|
resolveReconnectPolicy,
|
||||||
} from "../web/reconnect.js";
|
} from "../web/reconnect.js";
|
||||||
|
import {
|
||||||
|
ensureWebChatServerFromConfig,
|
||||||
|
startWebChatServer,
|
||||||
|
} from "../webchat/server.js";
|
||||||
import { createDefaultDeps, logWebSelfId } from "./deps.js";
|
import { createDefaultDeps, logWebSelfId } from "./deps.js";
|
||||||
|
|
||||||
export function buildProgram() {
|
export function buildProgram() {
|
||||||
|
|
@ -36,10 +35,7 @@ export function buildProgram() {
|
||||||
const TAGLINE =
|
const TAGLINE =
|
||||||
"Send, receive, and auto-reply on WhatsApp (web) and Telegram (bot).";
|
"Send, receive, and auto-reply on WhatsApp (web) and Telegram (bot).";
|
||||||
|
|
||||||
program
|
program.name("clawdis").description("").version(PROGRAM_VERSION);
|
||||||
.name("clawdis")
|
|
||||||
.description("")
|
|
||||||
.version(PROGRAM_VERSION);
|
|
||||||
|
|
||||||
const formatIntroLine = (version: string, rich = true) => {
|
const formatIntroLine = (version: string, rich = true) => {
|
||||||
const base = `📡 clawdis ${version} — ${TAGLINE}`;
|
const base = `📡 clawdis ${version} — ${TAGLINE}`;
|
||||||
|
|
@ -428,7 +424,11 @@ Examples:
|
||||||
"Run a heartbeat immediately when relay starts",
|
"Run a heartbeat immediately when relay starts",
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
.option("--webhook", "Run Telegram webhook server instead of long-poll", false)
|
.option(
|
||||||
|
"--webhook",
|
||||||
|
"Run Telegram webhook server instead of long-poll",
|
||||||
|
false,
|
||||||
|
)
|
||||||
.option(
|
.option(
|
||||||
"--webhook-path <path>",
|
"--webhook-path <path>",
|
||||||
"Telegram webhook path (default /telegram-webhook when webhook enabled)",
|
"Telegram webhook path (default /telegram-webhook when webhook enabled)",
|
||||||
|
|
@ -478,7 +478,6 @@ Examples:
|
||||||
startWeb = true;
|
startWeb = true;
|
||||||
startTelegram = true;
|
startTelegram = true;
|
||||||
break;
|
break;
|
||||||
case "auto":
|
|
||||||
default:
|
default:
|
||||||
startWeb = true;
|
startWeb = true;
|
||||||
startTelegram = Boolean(telegramToken);
|
startTelegram = Boolean(telegramToken);
|
||||||
|
|
@ -581,7 +580,10 @@ Examples:
|
||||||
cfg,
|
cfg,
|
||||||
webTuning.heartbeatSeconds,
|
webTuning.heartbeatSeconds,
|
||||||
);
|
);
|
||||||
const effectivePolicy = resolveReconnectPolicy(cfg, webTuning.reconnect);
|
const effectivePolicy = resolveReconnectPolicy(
|
||||||
|
cfg,
|
||||||
|
webTuning.reconnect,
|
||||||
|
);
|
||||||
defaultRuntime.log(
|
defaultRuntime.log(
|
||||||
info(
|
info(
|
||||||
`Web relay health: heartbeat ${effectiveHeartbeat}s, retries ${effectivePolicy.maxAttempts || "∞"}, backoff ${effectivePolicy.initialMs}→${effectivePolicy.maxMs}ms x${effectivePolicy.factor} (jitter ${Math.round(effectivePolicy.jitter * 100)}%)`,
|
`Web relay health: heartbeat ${effectiveHeartbeat}s, retries ${effectivePolicy.maxAttempts || "∞"}, backoff ${effectivePolicy.initialMs}→${effectivePolicy.maxMs}ms x${effectivePolicy.factor} (jitter ${Math.round(effectivePolicy.jitter * 100)}%)`,
|
||||||
|
|
@ -745,7 +747,9 @@ Shows token usage per session when the agent reports it; set inbound.reply.agent
|
||||||
.option("--port <port>", "Port to bind (default 18788)")
|
.option("--port <port>", "Port to bind (default 18788)")
|
||||||
.option("--json", "Return JSON", false)
|
.option("--json", "Return JSON", false)
|
||||||
.action(async (opts) => {
|
.action(async (opts) => {
|
||||||
const port = opts.port ? Number.parseInt(String(opts.port), 10) : undefined;
|
const port = opts.port
|
||||||
|
? Number.parseInt(String(opts.port), 10)
|
||||||
|
: undefined;
|
||||||
const server = await startWebChatServer(port);
|
const server = await startWebChatServer(port);
|
||||||
const payload = {
|
const payload = {
|
||||||
port: server.port,
|
port: server.port,
|
||||||
|
|
@ -755,7 +759,9 @@ Shows token usage per session when the agent reports it; set inbound.reply.agent
|
||||||
if (opts.json) {
|
if (opts.json) {
|
||||||
defaultRuntime.log(JSON.stringify(payload));
|
defaultRuntime.log(JSON.stringify(payload));
|
||||||
} else {
|
} else {
|
||||||
defaultRuntime.log(info(`webchat listening on http://127.0.0.1:${server.port}/webchat/`));
|
defaultRuntime.log(
|
||||||
|
info(`webchat listening on http://127.0.0.1:${server.port}/webchat/`),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,19 @@
|
||||||
import http from "node:http";
|
|
||||||
import path from "node:path";
|
|
||||||
import os from "node:os";
|
|
||||||
import { fileURLToPath } from "node:url";
|
|
||||||
import crypto from "node:crypto";
|
import crypto from "node:crypto";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
|
import http from "node:http";
|
||||||
|
import os from "node:os";
|
||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
|
|
||||||
|
import { agentCommand } from "../commands/agent.js";
|
||||||
import { loadConfig } from "../config/config.js";
|
import { loadConfig } from "../config/config.js";
|
||||||
import {
|
import {
|
||||||
loadSessionStore,
|
loadSessionStore,
|
||||||
resolveStorePath,
|
resolveStorePath,
|
||||||
type SessionEntry,
|
type SessionEntry,
|
||||||
} from "../config/sessions.js";
|
} from "../config/sessions.js";
|
||||||
import { danger, info } from "../globals.js";
|
|
||||||
import { logDebug } from "../logger.js";
|
import { logDebug } from "../logger.js";
|
||||||
import { agentCommand } from "../commands/agent.js";
|
|
||||||
import type { RuntimeEnv } from "../runtime.js";
|
import type { RuntimeEnv } from "../runtime.js";
|
||||||
|
|
||||||
const WEBCHAT_DEFAULT_PORT = 18788;
|
const WEBCHAT_DEFAULT_PORT = 18788;
|
||||||
|
|
@ -24,6 +23,14 @@ type WebChatServerState = {
|
||||||
port: number;
|
port: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type ChatMessage = { role: string; content: string };
|
||||||
|
type AttachmentInput = {
|
||||||
|
content?: string;
|
||||||
|
mimeType?: string;
|
||||||
|
fileName?: string;
|
||||||
|
type?: string;
|
||||||
|
};
|
||||||
|
|
||||||
let state: WebChatServerState | null = null;
|
let state: WebChatServerState | null = null;
|
||||||
|
|
||||||
function resolveWebRoot() {
|
function resolveWebRoot() {
|
||||||
|
|
@ -32,11 +39,17 @@ function resolveWebRoot() {
|
||||||
// 1) Packaged app: resources live next to the relay bundle at
|
// 1) Packaged app: resources live next to the relay bundle at
|
||||||
// Contents/Resources/WebChat. The relay binary runs from
|
// Contents/Resources/WebChat. The relay binary runs from
|
||||||
// Contents/Resources/Relay/bun, so walk up one and check.
|
// Contents/Resources/Relay/bun, so walk up one and check.
|
||||||
const packagedRoot = path.resolve(path.dirname(process.execPath), "../WebChat");
|
const packagedRoot = path.resolve(
|
||||||
|
path.dirname(process.execPath),
|
||||||
|
"../WebChat",
|
||||||
|
);
|
||||||
if (fs.existsSync(packagedRoot)) return packagedRoot;
|
if (fs.existsSync(packagedRoot)) return packagedRoot;
|
||||||
|
|
||||||
// 2) Dev / source checkout: repo-relative path.
|
// 2) Dev / source checkout: repo-relative path.
|
||||||
return path.resolve(here, "../../apps/macos/Sources/Clawdis/Resources/WebChat");
|
return path.resolve(
|
||||||
|
here,
|
||||||
|
"../../apps/macos/Sources/Clawdis/Resources/WebChat",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function readBody(req: http.IncomingMessage): Promise<Buffer> {
|
function readBody(req: http.IncomingMessage): Promise<Buffer> {
|
||||||
|
|
@ -49,15 +62,28 @@ function readBody(req: http.IncomingMessage): Promise<Buffer> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function pickSessionId(sessionKey: string, store: Record<string, SessionEntry>): string | null {
|
function pickSessionId(
|
||||||
|
sessionKey: string,
|
||||||
|
store: Record<string, SessionEntry>,
|
||||||
|
): string | null {
|
||||||
if (store[sessionKey]?.sessionId) return store[sessionKey].sessionId;
|
if (store[sessionKey]?.sessionId) return store[sessionKey].sessionId;
|
||||||
const first = Object.values(store)[0]?.sessionId;
|
const first = Object.values(store)[0]?.sessionId;
|
||||||
return first ?? null;
|
return first ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readSessionMessages(sessionId: string, storePath: string): any[] {
|
function readSessionMessages(
|
||||||
|
sessionId: string,
|
||||||
|
storePath: string,
|
||||||
|
): ChatMessage[] {
|
||||||
const dir = path.dirname(storePath);
|
const dir = path.dirname(storePath);
|
||||||
const candidates = [path.join(dir, `${sessionId}.jsonl`), path.join(os.homedir(), ".tau/agent/sessions/clawdis", `${sessionId}.jsonl`)];
|
const candidates = [
|
||||||
|
path.join(dir, `${sessionId}.jsonl`),
|
||||||
|
path.join(
|
||||||
|
os.homedir(),
|
||||||
|
".tau/agent/sessions/clawdis",
|
||||||
|
`${sessionId}.jsonl`,
|
||||||
|
),
|
||||||
|
];
|
||||||
let content: string | null = null;
|
let content: string | null = null;
|
||||||
for (const p of candidates) {
|
for (const p of candidates) {
|
||||||
if (fs.existsSync(p)) {
|
if (fs.existsSync(p)) {
|
||||||
|
|
@ -71,7 +97,7 @@ function readSessionMessages(sessionId: string, storePath: string): any[] {
|
||||||
}
|
}
|
||||||
if (!content) return [];
|
if (!content) return [];
|
||||||
|
|
||||||
const messages: any[] = [];
|
const messages: ChatMessage[] = [];
|
||||||
for (const line of content.split(/\r?\n/)) {
|
for (const line of content.split(/\r?\n/)) {
|
||||||
if (!line.trim()) continue;
|
if (!line.trim()) continue;
|
||||||
try {
|
try {
|
||||||
|
|
@ -87,22 +113,32 @@ function readSessionMessages(sessionId: string, storePath: string): any[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function persistAttachments(
|
async function persistAttachments(
|
||||||
attachments: any[],
|
attachments: AttachmentInput[],
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
): Promise<{ placeholder: string; path: string }[]> {
|
): Promise<{ placeholder: string; path: string }[]> {
|
||||||
const out: { placeholder: string; path: string }[] = [];
|
const out: { placeholder: string; path: string }[] = [];
|
||||||
if (!attachments?.length) return out;
|
if (!attachments?.length) return out;
|
||||||
|
|
||||||
const root = path.join(os.homedir(), ".clawdis", "webchat-uploads", sessionId);
|
const root = path.join(
|
||||||
|
os.homedir(),
|
||||||
|
".clawdis",
|
||||||
|
"webchat-uploads",
|
||||||
|
sessionId,
|
||||||
|
);
|
||||||
await fs.promises.mkdir(root, { recursive: true });
|
await fs.promises.mkdir(root, { recursive: true });
|
||||||
|
|
||||||
let idx = 1;
|
let idx = 1;
|
||||||
for (const att of attachments) {
|
for (const att of attachments) {
|
||||||
try {
|
try {
|
||||||
if (!att?.content || typeof att.content !== "string") continue;
|
if (!att?.content || typeof att.content !== "string") continue;
|
||||||
const mime = typeof att.mimeType === "string" ? att.mimeType : "application/octet-stream";
|
const mime =
|
||||||
|
typeof att.mimeType === "string"
|
||||||
|
? att.mimeType
|
||||||
|
: "application/octet-stream";
|
||||||
const baseName = att.fileName || `${att.type || "attachment"}-${idx}`;
|
const baseName = att.fileName || `${att.type || "attachment"}-${idx}`;
|
||||||
const ext = mime.startsWith("image/") ? mime.split("/")[1] || "bin" : "bin";
|
const ext = mime.startsWith("image/")
|
||||||
|
? mime.split("/")[1] || "bin"
|
||||||
|
: "bin";
|
||||||
const fileName = `${baseName}.${ext}`.replace(/[^a-zA-Z0-9._-]/g, "_");
|
const fileName = `${baseName}.${ext}`.replace(/[^a-zA-Z0-9._-]/g, "_");
|
||||||
const buf = Buffer.from(att.content, "base64");
|
const buf = Buffer.from(att.content, "base64");
|
||||||
|
|
||||||
|
|
@ -113,7 +149,8 @@ async function persistAttachments(
|
||||||
const image = sharp(buf, { failOn: "none" });
|
const image = sharp(buf, { failOn: "none" });
|
||||||
meta = await image.metadata();
|
meta = await image.metadata();
|
||||||
const needsResize =
|
const needsResize =
|
||||||
(meta.width && meta.width > 2000) || (meta.height && meta.height > 2000);
|
(meta.width && meta.width > 2000) ||
|
||||||
|
(meta.height && meta.height > 2000);
|
||||||
if (needsResize) {
|
if (needsResize) {
|
||||||
const resized = await image
|
const resized = await image
|
||||||
.resize({ width: 2000, height: 2000, fit: "inside" })
|
.resize({ width: 2000, height: 2000, fit: "inside" })
|
||||||
|
|
@ -137,7 +174,8 @@ async function persistAttachments(
|
||||||
await fs.promises.writeFile(dest, finalBuf);
|
await fs.promises.writeFile(dest, finalBuf);
|
||||||
|
|
||||||
const sizeLabel = `${(finalBuf.length / 1024).toFixed(0)} KB`;
|
const sizeLabel = `${(finalBuf.length / 1024).toFixed(0)} KB`;
|
||||||
const dimLabel = meta?.width && meta?.height ? `, ${meta.width}x${meta.height}` : "";
|
const dimLabel =
|
||||||
|
meta?.width && meta?.height ? `, ${meta.width}x${meta.height}` : "";
|
||||||
const placeholder = `[Attachment saved: ${dest} (${mime}${dimLabel}, ${sizeLabel})]`;
|
const placeholder = `[Attachment saved: ${dest} (${mime}${dimLabel}, ${sizeLabel})]`;
|
||||||
out.push({ placeholder, path: dest });
|
out.push({ placeholder, path: dest });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -149,16 +187,34 @@ async function persistAttachments(
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatMessageWithAttachments(text: string, saved: { placeholder: string }[]): string {
|
function formatMessageWithAttachments(
|
||||||
|
text: string,
|
||||||
|
saved: { placeholder: string }[],
|
||||||
|
): string {
|
||||||
if (!saved || saved.length === 0) return text;
|
if (!saved || saved.length === 0) return text;
|
||||||
const parts = [text, ...saved.map((s) => `\n\n${s.placeholder}`)];
|
const parts = [text, ...saved.map((s) => `\n\n${s.placeholder}`)];
|
||||||
return parts.join("");
|
return parts.join("");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleRpc(body: any, sessionKey: string): Promise<{ ok: boolean; payloads?: any[]; error?: string }> {
|
type RpcPayload = { role: string; content: string };
|
||||||
const text: string = (body?.text ?? "").toString();
|
|
||||||
|
async function handleRpc(
|
||||||
|
body: unknown,
|
||||||
|
sessionKey: string,
|
||||||
|
): Promise<{ ok: boolean; payloads?: RpcPayload[]; error?: string }> {
|
||||||
|
const payload = body as {
|
||||||
|
text?: unknown;
|
||||||
|
attachments?: unknown;
|
||||||
|
thinking?: unknown;
|
||||||
|
deliver?: unknown;
|
||||||
|
to?: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
const text: string = (payload.text ?? "").toString();
|
||||||
if (!text.trim()) return { ok: false, error: "empty text" };
|
if (!text.trim()) return { ok: false, error: "empty text" };
|
||||||
const attachments = Array.isArray(body?.attachments) ? body.attachments : [];
|
const attachments = Array.isArray(payload.attachments)
|
||||||
|
? (payload.attachments as AttachmentInput[])
|
||||||
|
: [];
|
||||||
|
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
const replyCfg = cfg.inbound?.reply;
|
const replyCfg = cfg.inbound?.reply;
|
||||||
|
|
@ -222,7 +278,10 @@ export async function startWebChatServer(port = WEBCHAT_DEFAULT_PORT) {
|
||||||
const server = http.createServer(async (req, res) => {
|
const server = http.createServer(async (req, res) => {
|
||||||
if (!req.url) return notFound(res);
|
if (!req.url) return notFound(res);
|
||||||
// enforce loopback only
|
// enforce loopback only
|
||||||
if (req.socket.remoteAddress && !req.socket.remoteAddress.startsWith("127.")) {
|
if (
|
||||||
|
req.socket.remoteAddress &&
|
||||||
|
!req.socket.remoteAddress.startsWith("127.")
|
||||||
|
) {
|
||||||
res.statusCode = 403;
|
res.statusCode = 403;
|
||||||
res.end("loopback only");
|
res.end("loopback only");
|
||||||
return;
|
return;
|
||||||
|
|
@ -241,7 +300,9 @@ export async function startWebChatServer(port = WEBCHAT_DEFAULT_PORT) {
|
||||||
: resolveStorePath(undefined);
|
: resolveStorePath(undefined);
|
||||||
const store = loadSessionStore(storePath);
|
const store = loadSessionStore(storePath);
|
||||||
const sessionId = pickSessionId(sessionKey, store);
|
const sessionId = pickSessionId(sessionKey, store);
|
||||||
const messages = sessionId ? readSessionMessages(sessionId, storePath) : [];
|
const messages = sessionId
|
||||||
|
? readSessionMessages(sessionId, storePath)
|
||||||
|
: [];
|
||||||
res.setHeader("Content-Type", "application/json");
|
res.setHeader("Content-Type", "application/json");
|
||||||
res.end(
|
res.end(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
|
|
@ -258,7 +319,7 @@ export async function startWebChatServer(port = WEBCHAT_DEFAULT_PORT) {
|
||||||
|
|
||||||
if (isRpc && req.method === "POST") {
|
if (isRpc && req.method === "POST") {
|
||||||
const bodyBuf = await readBody(req);
|
const bodyBuf = await readBody(req);
|
||||||
let body: any = {};
|
let body: Record<string, unknown> = {};
|
||||||
try {
|
try {
|
||||||
body = JSON.parse(bodyBuf.toString("utf-8"));
|
body = JSON.parse(bodyBuf.toString("utf-8"));
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -273,7 +334,7 @@ export async function startWebChatServer(port = WEBCHAT_DEFAULT_PORT) {
|
||||||
|
|
||||||
if (url.pathname.startsWith("/webchat")) {
|
if (url.pathname.startsWith("/webchat")) {
|
||||||
let rel = url.pathname.replace(/^\/webchat\/?/, "");
|
let rel = url.pathname.replace(/^\/webchat\/?/, "");
|
||||||
if (!rel || rel.endsWith("/")) rel = rel + "index.html";
|
if (!rel || rel.endsWith("/")) rel = `${rel}index.html`;
|
||||||
const filePath = path.join(root, rel);
|
const filePath = path.join(root, rel);
|
||||||
if (!filePath.startsWith(root)) return notFound(res);
|
if (!filePath.startsWith(root)) return notFound(res);
|
||||||
if (!fs.existsSync(filePath)) return notFound(res);
|
if (!fs.existsSync(filePath)) return notFound(res);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue