1
1
/* eslint-disable max-lines */
2
+ import type { AgnosticRouteObject } from '@remix-run/router' ;
3
+ import { isDeferredData , isRouteErrorResponse } from '@remix-run/router' ;
4
+ import type {
5
+ ActionFunction ,
6
+ ActionFunctionArgs ,
7
+ AppLoadContext ,
8
+ CreateRequestHandlerFunction ,
9
+ EntryContext ,
10
+ HandleDocumentRequestFunction ,
11
+ LoaderFunction ,
12
+ LoaderFunctionArgs ,
13
+ RequestHandler ,
14
+ ServerBuild ,
15
+ } from '@remix-run/server-runtime' ;
2
16
import type { RequestEventData , Span , TransactionSource , WrappedFunction } from '@sentry/core' ;
3
17
import {
4
18
continueTrace ,
@@ -22,23 +36,15 @@ import {
22
36
} from '@sentry/core' ;
23
37
import { DEBUG_BUILD } from '../utils/debug-build' ;
24
38
import { createRoutes , getTransactionName } from '../utils/utils' ;
25
- import { extractData , isDeferredData , isResponse , isRouteErrorResponse , json } from '../utils/vendor/response' ;
26
- import type {
27
- AppData ,
28
- AppLoadContext ,
29
- CreateRequestHandlerFunction ,
30
- DataFunction ,
31
- DataFunctionArgs ,
32
- EntryContext ,
33
- HandleDocumentRequestFunction ,
34
- RemixRequest ,
35
- RequestHandler ,
36
- ServerBuild ,
37
- ServerRoute ,
38
- ServerRouteManifest ,
39
- } from '../utils/vendor/types' ;
39
+ import { extractData , isResponse , json } from '../utils/vendor/response' ;
40
40
import { captureRemixServerException , errorHandleDataFunction , errorHandleDocumentRequestFunction } from './errors' ;
41
41
42
+ type AppData = unknown ;
43
+ type RemixRequest = Parameters < RequestHandler > [ 0 ] ;
44
+ type ServerRouteManifest = ServerBuild [ 'routes' ] ;
45
+ type DataFunction = LoaderFunction | ActionFunction ;
46
+ type DataFunctionArgs = LoaderFunctionArgs | ActionFunctionArgs ;
47
+
42
48
const redirectStatusCodes = new Set ( [ 301 , 302 , 303 , 307 , 308 ] ) ;
43
49
function isRedirectResponse ( response : Response ) : boolean {
44
50
return redirectStatusCodes . has ( response . status ) ;
@@ -261,7 +267,7 @@ function wrapRequestHandler(
261
267
return origRequestHandler . call ( this , request , loadContext ) ;
262
268
}
263
269
264
- let resolvedRoutes : ServerRoute [ ] | undefined ;
270
+ let resolvedRoutes : AgnosticRouteObject [ ] | undefined ;
265
271
266
272
if ( options ?. instrumentTracing ) {
267
273
if ( typeof build === 'function' ) {
@@ -428,7 +434,7 @@ export const makeWrappedCreateRequestHandler = (options?: { instrumentTracing?:
428
434
function ( origCreateRequestHandler : CreateRequestHandlerFunction ) : CreateRequestHandlerFunction {
429
435
return function (
430
436
this : unknown ,
431
- build : ServerBuild | ( ( ) => Promise < ServerBuild > ) ,
437
+ build : ServerBuild | ( ( ) => ServerBuild | Promise < ServerBuild > ) ,
432
438
...args : unknown [ ]
433
439
) : RequestHandler {
434
440
const newBuild = instrumentBuild ( build , options ) ;
0 commit comments