BREAKING CHANGE(typedserver): migrate route handlers to use IRequestContext and lazy body parsers
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user