diff --git a/src/client/index.html b/src/client/index.html
new file mode 100644
index 00000000..1d922c6f
--- /dev/null
+++ b/src/client/index.html
@@ -0,0 +1,43 @@
+
+
+
+ Counterfact
+
+
+
+
+
+ Counterfact is running!
+
+
+
diff --git a/src/server/start.js b/src/server/start.js
index 97eaeef1..dbe451b5 100644
--- a/src/server/start.js
+++ b/src/server/start.js
@@ -9,6 +9,9 @@ import { readFile } from "../util/read-file.js";
import { counterfact } from "./counterfact.js";
+// eslint-disable-next-line no-underscore-dangle
+const __dirname = nodePath.dirname(new URL(import.meta.url).pathname);
+
const DEFAULT_PORT = 3100;
function swaggerUi(app, openApiPath, port) {
@@ -44,46 +47,17 @@ function swaggerUi(app, openApiPath, port) {
);
}
-export function landingPageBody(basePath) {
- return `
-
-
- Counterfact
-
-
-
- Counterfact is running!
-
-
-
-`;
+export async function landingPageBody(basePath) {
+ const body = await readFile(nodePath.join(__dirname, "../client/index.html"));
+
+ return body.replaceAll("{{basePath}}", basePath);
}
export function landingPage(app, basePath) {
app.use(async (ctx, next) => {
if (ctx.URL.pathname === "/counterfact") {
- ctx.body = landingPageBody(basePath);
+ // eslint-disable-next-line require-atomic-updates
+ ctx.body = await landingPageBody(basePath);
return;
}
diff --git a/test/server/start.test.js b/test/server/start.test.js
index f7139c24..6760f4e3 100644
--- a/test/server/start.test.js
+++ b/test/server/start.test.js
@@ -1,9 +1,9 @@
import { landingPageBody } from "../../src/server/start.js";
describe("start", () => {
- it("renders the landing page", () => {
+ it("renders the landing page", async () => {
const basePath = "/home/user/counterfact";
- const result = landingPageBody(basePath);
+ const result = await landingPageBody(basePath);
expect(result).toContain(basePath);
});