@@ -52,7 +52,7 @@ import {
5252} from "@fedify/fedify/vocab" ;
5353import { getXForwardedRequest } from "@hongminhee/x-forwarded-fetch" ;
5454import metadata from "../deno.json" with { type : "json" } ;
55- import type { Bot , CreateBotOptions } from "./bot.ts" ;
55+ import type { Bot , CreateBotOptions , PagesOptions } from "./bot.ts" ;
5656import type {
5757 AcceptEventHandler ,
5858 FollowEventHandler ,
@@ -65,6 +65,7 @@ import type {
6565import { FollowRequestImpl } from "./follow-impl.ts" ;
6666import { createMessage , messageClasses } from "./message-impl.ts" ;
6767import type { Message , MessageClass } from "./message.ts" ;
68+ import { app } from "./pages.tsx" ;
6869import { KvRepository , type Repository , type Uuid } from "./repository.ts" ;
6970import { SessionImpl } from "./session-impl.ts" ;
7071import type { Session } from "./session.ts" ;
@@ -90,6 +91,7 @@ export class BotImpl<TContextData> implements Bot<TContextData> {
9091 readonly repository : Repository ;
9192 readonly software ?: Software ;
9293 readonly behindProxy : boolean ;
94+ readonly pages : Required < PagesOptions > ;
9395 readonly collectionWindow : number ;
9496 readonly federation : Federation < TContextData > ;
9597
@@ -115,6 +117,11 @@ export class BotImpl<TContextData> implements Bot<TContextData> {
115117 this . followerPolicy = options . followerPolicy ?? "accept" ;
116118 this . repository = options . repository ?? new KvRepository ( options . kv ) ;
117119 this . software = options . software ;
120+ this . pages = {
121+ color : "green" ,
122+ css : "" ,
123+ ...( options . pages ?? { } ) ,
124+ } ;
118125 this . federation = createFederation < TContextData > ( {
119126 kv : options . kv ,
120127 queue : options . queue ,
@@ -280,6 +287,7 @@ export class BotImpl<TContextData> implements Bot<TContextData> {
280287 outbox : ctx . getOutboxUri ( identifier ) ,
281288 publicKey : keyPairs [ 0 ] . cryptographicKey ,
282289 assertionMethods : keyPairs . map ( ( pair ) => pair . multikey ) ,
290+ url : new URL ( "/" , ctx . origin ) ,
283291 } ) ;
284292 }
285293
@@ -659,6 +667,14 @@ export class BotImpl<TContextData> implements Bot<TContextData> {
659667 if ( this . behindProxy ) {
660668 request = await getXForwardedRequest ( request ) ;
661669 }
662- return await this . federation . fetch ( request , { contextData } ) ;
670+ const url = new URL ( request . url ) ;
671+ if (
672+ url . pathname . startsWith ( "/.well-known/" ) ||
673+ url . pathname . startsWith ( "/ap/" ) ||
674+ url . pathname . startsWith ( "/nodeinfo/" )
675+ ) {
676+ return await this . federation . fetch ( request , { contextData } ) ;
677+ }
678+ return await app . fetch ( request , { bot : this , contextData } ) ;
663679 }
664680}
0 commit comments