UNPKG

@dudousxd/nestjs-telescope

Version:

Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.

42 lines 1.9 kB
function isPlainRecord(value) { return typeof value === 'object' && value !== null; } function isStringArray(value) { return value.every((item) => typeof item === 'string'); } /** * Narrows a raw platform request (typed `unknown` at the framework boundary, * e.g. `@Req() request: unknown`) into a {@link TelescopeHttpRequest} without an * unsafe cast. Every own-enumerable field passes through via the index * signature; `headers` entries that aren't `string | string[] | undefined` are * dropped rather than force-cast. A non-object input yields `{}`. */ export function toTelescopeHttpRequest(request) { if (!isPlainRecord(request)) return {}; const result = { ...request }; const headers = request.headers; if (isPlainRecord(headers)) { const normalizedHeaders = {}; for (const [key, value] of Object.entries(headers)) { if (typeof value === 'string' || value === undefined) { normalizedHeaders[key] = value; } else if (Array.isArray(value) && isStringArray(value)) { normalizedHeaders[key] = value; } } result.headers = normalizedHeaders; } return result; } export const TELESCOPE_OPTIONS = Symbol('TELESCOPE_OPTIONS'); export const TELESCOPE_STORAGE = Symbol('TELESCOPE_STORAGE'); export const TELESCOPE_CONFIG = Symbol('TELESCOPE_CONFIG'); /** Resolved `dashboardAuth` config (or `null` when unconfigured). Boot-validated. */ export const TELESCOPE_DASHBOARD_AUTH = Symbol('TELESCOPE_DASHBOARD_AUTH'); /** Kept for future DI use; the registry reads `options.queueManagers` directly. */ export const QUEUE_MANAGERS = Symbol('QUEUE_MANAGERS'); /** Resolved ExtensionRegistry (built + boot-validated from options.extensions). */ export const TELESCOPE_EXTENSIONS = Symbol('TELESCOPE_EXTENSIONS'); //# sourceMappingURL=telescope.options.js.map