@@ -11,7 +11,9 @@ import type * as mp from "./missing-parts";
11
11
12
12
export const validateEndpoint = async (
13
13
c : ExecutionContext ,
14
- endpoint : ep . AppEndpoint < mp . ServerContext , mp . DefaultStateInfo > ,
14
+ endpoint :
15
+ | ep . AppEndpoint < never , mp . DefaultStateInfo >
16
+ | ep . AppEndpoint < mp . ServerContext , mp . DefaultStateInfo > ,
15
17
getInstanceData : ( ) => ReadonlyArray < unknown > ,
16
18
prefix = "/api/something" ,
17
19
processFlattenedHandlerInfo : ( info : Array < unknown > ) => Array < unknown > = (
@@ -32,12 +34,19 @@ export const validateEndpoint = async (
32
34
) => {
33
35
c . truthy ( endpoint , "Given endpoint must be of given type" ) ;
34
36
35
- const { handler, url } = endpoint . getRegExpAndHandler ( "" ) ;
37
+ const finalized = endpoint . getRegExpAndHandler ( "" ) as ep . FinalizedAppEndpoint <
38
+ mp . ServerContext | never ,
39
+ mp . DefaultStateInfo
40
+ > ;
41
+ const { handler, url } = finalized ;
36
42
c . deepEqual (
37
43
url . source ,
38
44
`${ ep . escapeRegExp ( prefix ) . replaceAll ( "/" , "\\/" ) } \\/(?<urlParam>[^/]+)` ,
39
45
) ;
40
- const methodOK = handler (
46
+ const methodOK : ep . AppEndpointHandlerGetterResult <
47
+ mp . ServerContext | never ,
48
+ mp . DefaultStateInfo
49
+ > = handler (
41
50
method ,
42
51
// 2nd argument is not used by these endpoints, only by the ones produced by endpoint-prefix library
43
52
{ } ,
@@ -68,7 +77,7 @@ export const validateEndpoint = async (
68
77
] ) ,
69
78
) ;
70
79
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
71
- const args : ep . AppEndpointHandlerFunctionArgs < mp . ServerContext > =
80
+ const args : ep . AppEndpointHandlerFunctionArgs < mp . ServerContext | never > =
72
81
processHandlerArgs ( {
73
82
context : { req : "req" , res : "res" } ,
74
83
state : {
0 commit comments