fix: event types + emit subdomain serve event (#3137)

* fix: agents.md

* fix weird names

* fix: weird names again
This commit is contained in:
Daniel Salazar
2026-05-20 12:47:56 -07:00
committed by GitHub
parent a33d02f522
commit 84b48541bd
2 changed files with 27 additions and 1 deletions
+7
View File
@@ -204,6 +204,13 @@ export type EventMap = {
// ---- Subdomains ----
'subdomain.delete': { subdomain: string };
'subdomain.update': { subdomain: string };
'site.htmlServed': {
subdomain: string;
entry: unknown;
host: string;
requestPath: string;
mime: string;
};
// ---- Thumbnails ----
'thumbnail.read': {
+20 -1
View File
@@ -21,9 +21,9 @@ import type { RequestHandler } from 'express';
import { contentType as contentTypeFromMime } from 'mime-types';
import { posix as pathPosix } from 'node:path';
import type { puterClients } from '../../../clients';
import { FS_COSTS } from '../../../controllers/fs/costs';
import type { puterServices } from '../../../services';
import type { puterStores } from '../../../stores';
import { FS_COSTS } from '../../../controllers/fs/costs';
import type { IConfig, LayerInstances } from '../../../types';
import {
buildAppCenterFallback,
@@ -495,6 +495,25 @@ export const createPuterSiteMiddleware = (
const mime =
contentTypeFromMime(entry.name) || 'application/octet-stream';
res.setHeader('Content-Type', mime);
// Fire-and-forget signal for downstream extensions
if (mime === 'text/html' || mime === 'application/xhtml+xml') {
try {
layers.clients.event.emit(
'site.htmlServed',
{
subdomain,
entry,
host,
requestPath: req.path,
mime,
},
{},
);
} catch (e) {
console.warn('[puter-site] site.htmlServed emit failed', e);
}
}
if (download.contentLength !== null) {
res.setHeader('Content-Length', String(download.contentLength));
}