feat(serviceworker): Add TypedRequest traffic monitoring and SW dashboard Requests panel
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@api.global/typedserver',
|
||||
version: '7.7.1',
|
||||
version: '7.8.0',
|
||||
description: 'A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.'
|
||||
}
|
||||
|
||||
@@ -124,6 +124,65 @@ export class BuiltInRoutesController {
|
||||
});
|
||||
}
|
||||
|
||||
@plugins.smartserve.Get('/sw-dash')
|
||||
async getSwDash(ctx: plugins.smartserve.IRequestContext): Promise<Response> {
|
||||
// Import shared HTML from interfaces
|
||||
const { SW_DASH_HTML } = await import('../../dist_ts_interfaces/serviceworker.js');
|
||||
return new Response(SW_DASH_HTML, {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'text/html' },
|
||||
});
|
||||
}
|
||||
|
||||
// SW-dash data routes - return empty/unavailable when SW isn't active
|
||||
@plugins.smartserve.Get('/sw-dash/metrics')
|
||||
async getSwDashMetrics(): Promise<Response> {
|
||||
return new Response(JSON.stringify({ error: 'Service worker not active', data: null }), {
|
||||
status: 503,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
}
|
||||
|
||||
@plugins.smartserve.Get('/sw-dash/resources')
|
||||
async getSwDashResources(): Promise<Response> {
|
||||
return new Response(JSON.stringify({ error: 'Service worker not active', resources: [], domains: [], contentTypes: [], resourceCount: 0 }), {
|
||||
status: 503,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
}
|
||||
|
||||
@plugins.smartserve.Get('/sw-dash/events')
|
||||
async getSwDashEvents(): Promise<Response> {
|
||||
return new Response(JSON.stringify({ error: 'Service worker not active', events: [], total: 0 }), {
|
||||
status: 503,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
}
|
||||
|
||||
@plugins.smartserve.Get('/sw-dash/events/count')
|
||||
async getSwDashEventsCount(): Promise<Response> {
|
||||
return new Response(JSON.stringify({ error: 'Service worker not active', count: 0 }), {
|
||||
status: 503,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
}
|
||||
|
||||
@plugins.smartserve.Get('/sw-dash/cumulative-metrics')
|
||||
async getSwDashCumulativeMetrics(): Promise<Response> {
|
||||
return new Response(JSON.stringify({ error: 'Service worker not active', data: null }), {
|
||||
status: 503,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
}
|
||||
|
||||
@plugins.smartserve.Get('/sw-dash/speedtest')
|
||||
async getSwDashSpeedtest(): Promise<Response> {
|
||||
return new Response(JSON.stringify({ error: 'Service worker not active - speedtest unavailable' }), {
|
||||
status: 503,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
}
|
||||
|
||||
@plugins.smartserve.Get('/sw-dash/bundle.js')
|
||||
async getSwDashBundle(ctx: plugins.smartserve.IRequestContext): Promise<Response> {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user