···11import { Hono } from 'hono';
22-import { serveStatic } from 'hono/bun';
32import { getWispDomain, getCustomDomain, getCustomDomainByHash } from './lib/db';
43import { resolveDid, getPdsForDid, fetchSiteRecord, downloadAndCacheSite, getCachedFilePath, isCached, sanitizePath } from './lib/utils';
54import { rewriteHtmlPaths, isHtmlContent } from './lib/html-rewriter';
66-import { existsSync } from 'fs';
55+import { existsSync, readFileSync } from 'fs';
66+import { lookup } from 'mime-types';
7788const app = new Hono();
99···3333 const cachedFile = getCachedFilePath(did, rkey, requestPath);
34343535 if (existsSync(cachedFile)) {
3636- const file = Bun.file(cachedFile);
3737- return new Response(file, {
3636+ const content = readFileSync(cachedFile);
3737+ const mimeType = lookup(cachedFile) || 'application/octet-stream';
3838+ return new Response(content, {
3839 headers: {
3939- 'Content-Type': file.type || 'application/octet-stream',
4040+ 'Content-Type': mimeType,
4041 },
4142 });
4243 }
···4546 if (!requestPath.includes('.')) {
4647 const indexFile = getCachedFilePath(did, rkey, `${requestPath}/index.html`);
4748 if (existsSync(indexFile)) {
4848- const file = Bun.file(indexFile);
4949- return new Response(file, {
4949+ const content = readFileSync(indexFile);
5050+ return new Response(content, {
5051 headers: {
5152 'Content-Type': 'text/html; charset=utf-8',
5253 },
···7374 const cachedFile = getCachedFilePath(did, rkey, requestPath);
74757576 if (existsSync(cachedFile)) {
7676- const file = Bun.file(cachedFile);
7777+ const mimeType = lookup(cachedFile) || 'application/octet-stream';
77787879 // Check if this is HTML content that needs rewriting
7979- if (isHtmlContent(requestPath, file.type)) {
8080- const content = await file.text();
8080+ if (isHtmlContent(requestPath, mimeType)) {
8181+ const content = readFileSync(cachedFile, 'utf-8');
8182 const rewritten = rewriteHtmlPaths(content, basePath);
8283 return new Response(rewritten, {
8384 headers: {
···8788 }
88898990 // Non-HTML files served with proper MIME type
9090- return new Response(file, {
9191+ const content = readFileSync(cachedFile);
9292+ return new Response(content, {
9193 headers: {
9292- 'Content-Type': file.type || 'application/octet-stream',
9494+ 'Content-Type': mimeType,
9395 },
9496 });
9597 }
···98100 if (!requestPath.includes('.')) {
99101 const indexFile = getCachedFilePath(did, rkey, `${requestPath}/index.html`);
100102 if (existsSync(indexFile)) {
101101- const file = Bun.file(indexFile);
102102- const content = await file.text();
103103+ const content = readFileSync(indexFile, 'utf-8');
103104 const rewritten = rewriteHtmlPaths(content, basePath);
104105 return new Response(rewritten, {
105106 headers: {
-1
src/index.ts
···11import { Elysia } from 'elysia'
22import { cors } from '@elysiajs/cors'
33import { staticPlugin } from '@elysiajs/static'
44-import { openapi, fromTypes } from '@elysiajs/openapi'
5465import type { Config } from './lib/types'
76import { BASE_HOST } from './lib/constants'
+44
src/lexicons/index.ts
···11+/**
22+ * GENERATED CODE - DO NOT MODIFY
33+ */
44+import {
55+ type Auth,
66+ type Options as XrpcOptions,
77+ Server as XrpcServer,
88+ type StreamConfigOrHandler,
99+ type MethodConfigOrHandler,
1010+ createServer as createXrpcServer,
1111+} from '@atproto/xrpc-server'
1212+import { schemas } from './lexicons.js'
1313+1414+export function createServer(options?: XrpcOptions): Server {
1515+ return new Server(options)
1616+}
1717+1818+export class Server {
1919+ xrpc: XrpcServer
2020+ place: PlaceNS
2121+2222+ constructor(options?: XrpcOptions) {
2323+ this.xrpc = createXrpcServer(schemas, options)
2424+ this.place = new PlaceNS(this)
2525+ }
2626+}
2727+2828+export class PlaceNS {
2929+ _server: Server
3030+ wisp: PlaceWispNS
3131+3232+ constructor(server: Server) {
3333+ this._server = server
3434+ this.wisp = new PlaceWispNS(server)
3535+ }
3636+}
3737+3838+export class PlaceWispNS {
3939+ _server: Server
4040+4141+ constructor(server: Server) {
4242+ this._server = server
4343+ }
4444+}