···1import { Hono } from 'hono';
2-import { serveStatic } from 'hono/bun';
3import { getWispDomain, getCustomDomain, getCustomDomainByHash } from './lib/db';
4import { resolveDid, getPdsForDid, fetchSiteRecord, downloadAndCacheSite, getCachedFilePath, isCached, sanitizePath } from './lib/utils';
5import { rewriteHtmlPaths, isHtmlContent } from './lib/html-rewriter';
6-import { existsSync } from 'fs';
078const app = new Hono();
9···33 const cachedFile = getCachedFilePath(did, rkey, requestPath);
3435 if (existsSync(cachedFile)) {
36- const file = Bun.file(cachedFile);
37- return new Response(file, {
038 headers: {
39- 'Content-Type': file.type || 'application/octet-stream',
40 },
41 });
42 }
···45 if (!requestPath.includes('.')) {
46 const indexFile = getCachedFilePath(did, rkey, `${requestPath}/index.html`);
47 if (existsSync(indexFile)) {
48- const file = Bun.file(indexFile);
49- return new Response(file, {
50 headers: {
51 'Content-Type': 'text/html; charset=utf-8',
52 },
···73 const cachedFile = getCachedFilePath(did, rkey, requestPath);
7475 if (existsSync(cachedFile)) {
76- const file = Bun.file(cachedFile);
7778 // Check if this is HTML content that needs rewriting
79- if (isHtmlContent(requestPath, file.type)) {
80- const content = await file.text();
81 const rewritten = rewriteHtmlPaths(content, basePath);
82 return new Response(rewritten, {
83 headers: {
···87 }
8889 // Non-HTML files served with proper MIME type
90- return new Response(file, {
091 headers: {
92- 'Content-Type': file.type || 'application/octet-stream',
93 },
94 });
95 }
···98 if (!requestPath.includes('.')) {
99 const indexFile = getCachedFilePath(did, rkey, `${requestPath}/index.html`);
100 if (existsSync(indexFile)) {
101- const file = Bun.file(indexFile);
102- const content = await file.text();
103 const rewritten = rewriteHtmlPaths(content, basePath);
104 return new Response(rewritten, {
105 headers: {
···1import { Hono } from 'hono';
02import { getWispDomain, getCustomDomain, getCustomDomainByHash } from './lib/db';
3import { resolveDid, getPdsForDid, fetchSiteRecord, downloadAndCacheSite, getCachedFilePath, isCached, sanitizePath } from './lib/utils';
4import { rewriteHtmlPaths, isHtmlContent } from './lib/html-rewriter';
5+import { existsSync, readFileSync } from 'fs';
6+import { lookup } from 'mime-types';
78const app = new Hono();
9···33 const cachedFile = getCachedFilePath(did, rkey, requestPath);
3435 if (existsSync(cachedFile)) {
36+ const content = readFileSync(cachedFile);
37+ const mimeType = lookup(cachedFile) || 'application/octet-stream';
38+ return new Response(content, {
39 headers: {
40+ 'Content-Type': mimeType,
41 },
42 });
43 }
···46 if (!requestPath.includes('.')) {
47 const indexFile = getCachedFilePath(did, rkey, `${requestPath}/index.html`);
48 if (existsSync(indexFile)) {
49+ const content = readFileSync(indexFile);
50+ return new Response(content, {
51 headers: {
52 'Content-Type': 'text/html; charset=utf-8',
53 },
···74 const cachedFile = getCachedFilePath(did, rkey, requestPath);
7576 if (existsSync(cachedFile)) {
77+ const mimeType = lookup(cachedFile) || 'application/octet-stream';
7879 // Check if this is HTML content that needs rewriting
80+ if (isHtmlContent(requestPath, mimeType)) {
81+ const content = readFileSync(cachedFile, 'utf-8');
82 const rewritten = rewriteHtmlPaths(content, basePath);
83 return new Response(rewritten, {
84 headers: {
···88 }
8990 // Non-HTML files served with proper MIME type
91+ const content = readFileSync(cachedFile);
92+ return new Response(content, {
93 headers: {
94+ 'Content-Type': mimeType,
95 },
96 });
97 }
···100 if (!requestPath.includes('.')) {
101 const indexFile = getCachedFilePath(did, rkey, `${requestPath}/index.html`);
102 if (existsSync(indexFile)) {
103+ const content = readFileSync(indexFile, 'utf-8');
0104 const rewritten = rewriteHtmlPaths(content, basePath);
105 return new Response(rewritten, {
106 headers: {
-1
src/index.ts
···1import { Elysia } from 'elysia'
2import { cors } from '@elysiajs/cors'
3import { staticPlugin } from '@elysiajs/static'
4-import { openapi, fromTypes } from '@elysiajs/openapi'
56import type { Config } from './lib/types'
7import { BASE_HOST } from './lib/constants'
···1import { Elysia } from 'elysia'
2import { cors } from '@elysiajs/cors'
3import { staticPlugin } from '@elysiajs/static'
045import type { Config } from './lib/types'
6import { BASE_HOST } from './lib/constants'
+44
src/lexicons/index.ts
···00000000000000000000000000000000000000000000
···1+/**
2+ * GENERATED CODE - DO NOT MODIFY
3+ */
4+import {
5+ type Auth,
6+ type Options as XrpcOptions,
7+ Server as XrpcServer,
8+ type StreamConfigOrHandler,
9+ type MethodConfigOrHandler,
10+ createServer as createXrpcServer,
11+} from '@atproto/xrpc-server'
12+import { schemas } from './lexicons.js'
13+14+export function createServer(options?: XrpcOptions): Server {
15+ return new Server(options)
16+}
17+18+export class Server {
19+ xrpc: XrpcServer
20+ place: PlaceNS
21+22+ constructor(options?: XrpcOptions) {
23+ this.xrpc = createXrpcServer(schemas, options)
24+ this.place = new PlaceNS(this)
25+ }
26+}
27+28+export class PlaceNS {
29+ _server: Server
30+ wisp: PlaceWispNS
31+32+ constructor(server: Server) {
33+ this._server = server
34+ this.wisp = new PlaceWispNS(server)
35+ }
36+}
37+38+export class PlaceWispNS {
39+ _server: Server
40+41+ constructor(server: Server) {
42+ this._server = server
43+ }
44+}