feat(website-server): Add configurable ads.txt support to website server

This commit is contained in:
2025-12-05 15:27:54 +00:00
parent 94c6e47e6e
commit d060d99146
3 changed files with 20 additions and 9 deletions

View File

@@ -23,6 +23,8 @@ export interface IUtilityWebsiteServerConstructorOptions {
forceSsl?: boolean;
/** Port to listen on (default: 3000) */
port?: number;
/** ads.txt entries (only served if configured) */
adsTxt?: string[];
}
/**
@@ -94,15 +96,16 @@ export class UtilityWebsiteServer {
})
);
// ads.txt handler
this.typedserver.addRoute('/ads.txt', 'GET', async () => {
const adsTxt =
['google.com, pub-4104137977476459, DIRECT, f08c47fec0942fa0'].join('\n') + '\n';
return new Response(adsTxt, {
status: 200,
headers: { 'Content-Type': 'text/plain' },
// ads.txt handler (only if configured)
if (this.options.adsTxt && this.options.adsTxt.length > 0) {
this.typedserver.addRoute('/ads.txt', 'GET', async () => {
const adsTxt = this.options.adsTxt.join('\n') + '\n';
return new Response(adsTxt, {
status: 200,
headers: { 'Content-Type': 'text/plain' },
});
});
});
}
// Asset broker manifest handler
this.typedserver.addRoute(