feat(content): serve the mounted content folder under /content (spec 003)
Audio with range requests, library.json, Homer books; LRC parser. Content stays out of git and the image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d063fcbe0
commit
27b1d2fe26
15 files changed
+527
-10
No files matched your search
+10
-3
@@ -1,4 +1,5 @@
|
||||
import type { Server } from "bun";
|
||||
import { contentResponse } from "./content/routes";
|
||||
import home from "./index.html";
|
||||
import m0 from "./mockups/01-editorial/index.html";
|
||||
import m1 from "./mockups/02-vertical-story/index.html";
|
||||
@@ -17,7 +18,13 @@ import m13 from "./mockups/14-voyage-panel/index.html";
|
||||
import m14 from "./mockups/15-voyage-look2/index.html";
|
||||
import m15 from "./mockups/16-voyage-readable/index.html";
|
||||
|
||||
export function startServer(port: number): Server<undefined> {
|
||||
export interface ServerOptions {
|
||||
/** Folder with the real content (audio, lyrics, Homer); defaults to CONTENT_DIR. See spec 003. */
|
||||
contentDir?: string;
|
||||
}
|
||||
|
||||
export function startServer(port: number, opts: ServerOptions = {}): Server<undefined> {
|
||||
const contentDir = "contentDir" in opts ? opts.contentDir : process.env.CONTENT_DIR;
|
||||
return Bun.serve({
|
||||
port,
|
||||
routes: {
|
||||
@@ -56,8 +63,8 @@ export function startServer(port: number): Server<undefined> {
|
||||
"/mockups/16-voyage-readable": Response.redirect("/mockups/16-voyage-readable/", 302),
|
||||
},
|
||||
development: process.env.NODE_ENV !== "production",
|
||||
fetch() {
|
||||
return new Response("Not found", { status: 404 });
|
||||
fetch(req) {
|
||||
return contentResponse(req, contentDir) ?? new Response("Not found", { status: 404 });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user