11import { Request , Response } from "express" ;
22import * as R from "ramda" ;
3- import { z } from "zod" ;
3+ import { globalRegistry , z } from "zod" ;
44import { NormalizedResponse , ResponseVariant } from "./api-response" ;
5- import { hasForm , hasRaw , hasUpload } from "./deep-checks" ;
5+ import { findRequestTypeDefiningSchema } from "./deep-checks" ;
66import {
77 FlatObject ,
88 getActualMethod ,
@@ -15,16 +15,20 @@ import {
1515 OutputValidationError ,
1616 ResultHandlerError ,
1717} from "./errors" ;
18+ import { ezFormBrand } from "./form-schema" ;
1819import { IOSchema } from "./io-schema" ;
1920import { lastResortHandler } from "./last-resort" ;
2021import { ActualLogger } from "./logger-helpers" ;
2122import { LogicalContainer } from "./logical-container" ;
23+ import { metaSymbol } from "./metadata" ;
2224import { AuxMethod , Method } from "./method" ;
2325import { AbstractMiddleware , ExpressMiddleware } from "./middleware" ;
2426import { ContentType } from "./content-type" ;
27+ import { ezRawBrand } from "./raw-schema" ;
2528import { Routable } from "./routable" ;
2629import { AbstractResultHandler } from "./result-handler" ;
2730import { Security } from "./security" ;
31+ import { ezUploadBrand } from "./upload-schema" ;
2832
2933export type Handler < IN , OUT , OPT > = ( params : {
3034 /** @desc The inputs from the enabled input sources validated against the final input schema (incl. Middlewares) */
@@ -137,13 +141,14 @@ export class Endpoint<
137141
138142 /** @internal */
139143 public override get requestType ( ) {
140- return hasUpload ( this . #def. inputSchema )
141- ? "upload"
142- : hasRaw ( this . #def. inputSchema )
143- ? "raw"
144- : hasForm ( this . #def. inputSchema )
145- ? "form"
146- : "json" ;
144+ const found = findRequestTypeDefiningSchema ( this . #def. inputSchema ) ;
145+ if ( found ) {
146+ const { brand } = globalRegistry . get ( found ) ?. [ metaSymbol ] || { } ;
147+ if ( brand === ezUploadBrand ) return "upload" ;
148+ if ( brand === ezRawBrand ) return "raw" ;
149+ if ( brand === ezFormBrand ) return "form" ;
150+ }
151+ return "json" ;
147152 }
148153
149154 /** @internal */
0 commit comments