about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.ts9
-rw-r--r--src/index.ts10
2 files changed, 17 insertions, 2 deletions
diff --git a/src/config.ts b/src/config.ts
new file mode 100644
index 0000000..064b038
--- /dev/null
+++ b/src/config.ts
@@ -0,0 +1,9 @@
+import path from "node:path";
+import fs from "node:fs";
+import toml from "toml";
+
+export default function readConfig(base: string) {
+  const filename = path.join(base, "config.toml");
+
+  return toml.parse(fs.readFileSync(filename, "utf-8"));
+}
diff --git a/src/index.ts b/src/index.ts
index 4887dd6..d8c9bf1 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,10 +1,16 @@
+import path from "node:path";
 import { withHtmlLiveReload } from "bun-html-live-reload";
 import serveStatic from "serve-static-bun";
 
-const dir = Bun.argv.length > 2 ? Bun.argv[Bun.argv.length - 1] : "./";
+import readConfig from "./config";
+
+const base = Bun.argv.length > 2 ? Bun.argv[Bun.argv.length - 1] : ".";
+
+const config = readConfig(base);
 
 export default withHtmlLiveReload({
-  fetch: serveStatic(dir, {
+  fetch: serveStatic(path.join(base, "public"), {
+    headers: config.extra.headers,
     dotfiles: "allow",
   }),
 });