From d060d991464fdc7e8d56e4fa303a0aa5486a2707 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Fri, 5 Dec 2025 15:27:54 +0000 Subject: [PATCH] feat(website-server): Add configurable ads.txt support to website server --- changelog.md | 8 ++++++++ ts/00_commitinfo_data.ts | 2 +- ts/utilityservers/classes.websiteserver.ts | 19 +++++++++++-------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index 35a5186..da42f92 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2025-12-05 - 7.10.0 - feat(website-server) +Add configurable ads.txt support to website server + +- Introduce adsTxt?: string[] option to the server options to allow configuring ads.txt entries. +- Serve /ads.txt only when adsTxt is provided; the route is not registered if no entries are configured. +- Replace previous hard-coded Google ads.txt entry with values joined from the provided adsTxt array and served as text/plain. +- Preserves existing behavior when adsTxt is not set (no /ads.txt endpoint will be exposed). + ## 2025-12-05 - 7.9.0 - feat(typedserver) Add configurable security headers and default SPA behavior diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index e8c80bc..7afbf5a 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@api.global/typedserver', - version: '7.9.0', + version: '7.10.0', description: 'A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.' } diff --git a/ts/utilityservers/classes.websiteserver.ts b/ts/utilityservers/classes.websiteserver.ts index b8ff306..aef796a 100644 --- a/ts/utilityservers/classes.websiteserver.ts +++ b/ts/utilityservers/classes.websiteserver.ts @@ -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(