Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
kainpets committed Oct 11, 2023
1 parent 9d689b2 commit 6aa8520
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions packages/nextlove/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export type MiddlewareChainOutput<
? {}
: MWChain extends readonly [infer First, ...infer Rest]
? First extends Middleware<infer T, any>
? T &
(Rest extends readonly Middleware<any, any>[]
? MiddlewareChainOutput<Rest>
: never)
: never
? T &
(Rest extends readonly Middleware<any, any>[]
? MiddlewareChainOutput<Rest>
: never)
: never
: never

export type AuthMiddlewares = {
Expand Down Expand Up @@ -117,34 +117,34 @@ export type RouteFunction<
> = (
req: (SP["authMiddlewareMap"] &
typeof defaultMiddlewareMap)[RS["auth"]] extends Middleware<
infer AuthMWOut,
any
>
infer AuthMWOut,
any
>
? Omit<NextApiRequest, "query" | "body"> &
AuthMWOut &
MiddlewareChainOutput<
RS["middlewares"] extends readonly Middleware<any, any>[]
? [...SP["globalMiddlewares"], ...RS["middlewares"]]
: SP["globalMiddlewares"]
> & {
body: RS["formData"] extends z.ZodTypeAny
? z.infer<RS["formData"]>
: RS["jsonBody"] extends z.ZodTypeAny
? z.infer<RS["jsonBody"]>
: {}
query: RS["queryParams"] extends z.ZodTypeAny
? z.infer<RS["queryParams"]>
: {}
commonParams: RS["commonParams"] extends z.ZodTypeAny
? z.infer<RS["commonParams"]>
: {}
}
AuthMWOut &
MiddlewareChainOutput<
RS["middlewares"] extends readonly Middleware<any, any>[]
? [...SP["globalMiddlewares"], ...RS["middlewares"]]
: SP["globalMiddlewares"]
> & {
body: RS["formData"] extends z.ZodTypeAny
? z.infer<RS["formData"]>
: RS["jsonBody"] extends z.ZodTypeAny
? z.infer<RS["jsonBody"]>
: {}
query: RS["queryParams"] extends z.ZodTypeAny
? z.infer<RS["queryParams"]>
: {}
commonParams: RS["commonParams"] extends z.ZodTypeAny
? z.infer<RS["commonParams"]>
: {}
}
: `unknown auth type: ${RS["auth"]}. You should configure this auth type in your auth_middlewares w/ createWithRouteSpec, or maybe you need to add "as const" to your route spec definition.`,
res: NextApiResponseWithoutJsonAndStatusMethods &
SuccessfulNextApiResponseMethods<
RS["jsonResponse"] extends z.ZodTypeAny
? z.infer<RS["jsonResponse"]>
: any
? z.infer<RS["jsonResponse"]>
: any
> &
ErrorNextApiResponseMethods
) => Promise<void>
Expand Down

0 comments on commit 6aa8520

Please sign in to comment.