BREAKING CHANGE(typedserver): migrate route handlers to use IRequestContext and lazy body parsers

This commit is contained in:
2025-12-20 08:11:04 +00:00
parent d5800f58b4
commit 64f8f400c2
12 changed files with 193 additions and 127 deletions

View File

@@ -10,9 +10,10 @@ export class DevToolsController {
private getLastReload: () => number;
private getEnded: () => boolean;
constructor(options: { getLastReload: () => number; getEnded: () => boolean }) {
this.getLastReload = options.getLastReload;
this.getEnded = options.getEnded;
constructor(options?: { getLastReload: () => number; getEnded: () => boolean }) {
// Default no-op functions for when controller is auto-instantiated without options
this.getLastReload = options?.getLastReload ?? (() => 0);
this.getEnded = options?.getEnded ?? (() => false);
}
@plugins.smartserve.Get('/devtools')

View File

@@ -14,7 +14,8 @@ export class TypedRequestController {
@plugins.smartserve.Post('')
async handleTypedRequest(ctx: plugins.smartserve.IRequestContext): Promise<Response> {
try {
const response = await this.typedRouter.routeAndAddResponse(ctx.body as plugins.typedrequestInterfaces.ITypedRequest);
const body = await ctx.json() as plugins.typedrequestInterfaces.ITypedRequest;
const response = await this.typedRouter.routeAndAddResponse(body);
return new Response(plugins.smartjson.stringify(response), {
status: 200,