all repos — archive/homestead @ 51cc4389f6dc7947ee34d1b3367876941e8a8fbc

My future indieweb platform

Serve static files

Alan Pearce
commit

51cc4389f6dc7947ee34d1b3367876941e8a8fbc

parent

a25028aa30bf0f3b89a9a7c99192e1a14267fc97

5 files changed, 18 insertions(+), 10 deletions(-)

jump to
M README.mdREADME.md
@@ -2,8 +2,9 @@ # homestead
## Goals -1. To be a near-drop-in replacement for Zola -2. More indieweb features +1. Static web server with prometheus-based analytics +2. Dynamic web server capable of generating Zola-based websites +3. More indieweb features ## Installing
M bun.lockbbun.lockb

Not showing binary file.

M package.jsonpackage.json
@@ -10,6 +10,6 @@ "typescript": "^5.0.0"
}, "type": "module", "dependencies": { - "siopao": "^0.4.0" + "serve-static-bun": "^0.5.3" } }
M src/index.tssrc/index.ts
@@ -1,10 +1,10 @@
-import { withHtmlLiveReload } from "bun-html-live-reload"; -import Siopao from "siopao"; - -const router = new Siopao(); +import { withHtmlLiveReload } from "bun-html-live-reload" +import serveStatic from "serve-static-bun" -router.get("/status", () => new Response("OK")); +const dir = Bun.argv.length > 2 ? Bun.argv[Bun.argv.length - 1] : "./" export default withHtmlLiveReload({ - fetch: router.fetch.bind(router), + fetch: serveStatic(dir, { + dotfiles: "allow" + }), })
M test/index.test.tstest/index.test.ts
@@ -4,6 +4,7 @@
import app from "../src/index" const port = 33000; +const base = `http://localhost:${port}/`; let server: Server beforeAll(async function () {
@@ -15,7 +16,13 @@ server.stop()
}) test("/status returns 200 OK", async function () { - const res = await fetch(`http://localhost:${port}/status`) + const res = await fetch(new URL("/status", base)) expect(res.status).toBe(200) expect(await res.text()).toBe("OK") }) + +test("/ returns 200 and says Hello world", async function () { + const res = await fetch(base) + expect(res.status).toBe(200) + expect(await res.text()).toBe("Hello world") +})