Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { ensureDockerBasePath } from "../../scripts/docker/ensure-docker-base-path.mjs";
function makeStandaloneRoot(basePath = "") {
const appRoot = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-docker-base-"));
const distRoot = path.join(appRoot, ".build", "next");
fs.mkdirSync(path.join(distRoot, "server"), { recursive: true });
fs.writeFileSync(
path.join(distRoot, "routes-manifest.json"),
JSON.stringify({ basePath })
);
fs.writeFileSync(
path.join(distRoot, "server", "chunk.js"),
`export const config={basePath:"${basePath}"};`
);
fs.writeFileSync(path.join(appRoot, "BUILD_OMNIROUTE_BASE_PATH"), `${basePath}\n`);
return appRoot;
}
test("ensureDockerBasePath is a no-op when runtime matches the baked sentinel", () => {
const appRoot = makeStandaloneRoot("");
const result = ensureDockerBasePath({ appRoot, env: { OMNIROUTE_BASE_PATH: "" } });
assert.equal(result.action, "noop");
});
test("ensureDockerBasePath patches a root image when a subpath is configured", () => {
const appRoot = makeStandaloneRoot("");
const result = ensureDockerBasePath({ appRoot, env: { OMNIROUTE_BASE_PATH: "/omniroute" } });
assert.equal(result.action, "patched");
assert.equal(fs.readFileSync(path.join(appRoot, "BUILD_OMNIROUTE_BASE_PATH"), "utf8"), "/omniroute\n");
const manifest = JSON.parse(
fs.readFileSync(path.join(appRoot, ".build", "next", "routes-manifest.json"), "utf8")
);
assert.equal(manifest.basePath, "/omniroute");
});
test("ensureDockerBasePath rejects unset runtime on subpath images", () => {
const appRoot = makeStandaloneRoot("/omniroute");
assert.throws(
() => ensureDockerBasePath({ appRoot, env: {} }),
/built for subpath/
);
});