- Removed legacy servertools and Express dependencies in favor of SmartServe. - Introduced DevToolsHandler and TypedRequestHandler for handling specific routes. - Added support for custom route registration with regex parsing. - Implemented sitemap and feed handling with dedicated helper classes. - Enhanced HTML response handling with reload script injection. - Updated UtilityServiceServer and UtilityWebsiteServer to utilize new TypedServer API. - Removed deprecated compression options and Express-based route handling. - Added comprehensive request handling for various endpoints including robots.txt, manifest.json, and sitemap. - Improved error handling and response formatting across the server.
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import * as plugins from '../plugins.js';
|
|
import * as paths from '../paths.js';
|
|
|
|
/**
|
|
* DevTools controller for TypedServer
|
|
* Handles /typedserver/devtools and /typedserver/reloadcheck endpoints
|
|
*/
|
|
@plugins.smartserve.Route('/typedserver')
|
|
export class DevToolsController {
|
|
private getLastReload: () => number;
|
|
private getEnded: () => boolean;
|
|
|
|
constructor(options: { getLastReload: () => number; getEnded: () => boolean }) {
|
|
this.getLastReload = options.getLastReload;
|
|
this.getEnded = options.getEnded;
|
|
}
|
|
|
|
@plugins.smartserve.Get('/devtools')
|
|
async getDevtools(ctx: plugins.smartserve.IRequestContext): Promise<Response> {
|
|
const devtoolsContent = (await plugins.fsInstance
|
|
.file(paths.injectBundlePath)
|
|
.encoding('utf8')
|
|
.read()) as string;
|
|
|
|
return new Response(devtoolsContent, {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'text/javascript',
|
|
},
|
|
});
|
|
}
|
|
|
|
@plugins.smartserve.Get('/reloadcheck')
|
|
async reloadCheck(ctx: plugins.smartserve.IRequestContext): Promise<Response> {
|
|
console.log('got request for reloadcheck');
|
|
|
|
if (this.getEnded()) {
|
|
return new Response('end', {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'text/plain',
|
|
},
|
|
});
|
|
}
|
|
|
|
return new Response(this.getLastReload().toString(), {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'text/plain',
|
|
},
|
|
});
|
|
}
|
|
}
|