File tree 6 files changed +5
-112
lines changed
6 files changed +5
-112
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,6 @@ export type HandlerOptions<Context extends OperationContext = undefined> =
43
43
export function createHandler < Context extends OperationContext = undefined > (
44
44
options : HandlerOptions < Context > ,
45
45
) : Handler {
46
- const isProd = process . env . NODE_ENV === 'production' ;
47
46
const handle = createRawHandler ( options ) ;
48
47
return async function requestListener ( req , res ) {
49
48
try {
@@ -74,24 +73,7 @@ export function createHandler<Context extends OperationContext = undefined>(
74
73
'Please check your implementation.' ,
75
74
err ,
76
75
) ;
77
- if ( isProd ) {
78
- res . writeHead ( 500 ) . end ( ) ;
79
- } else {
80
- res
81
- . writeHead ( 500 , { 'content-type' : 'application/json; charset=utf-8' } )
82
- . end (
83
- JSON . stringify ( {
84
- errors : [
85
- err instanceof Error
86
- ? {
87
- message : err . message ,
88
- stack : err . stack ,
89
- }
90
- : err ,
91
- ] ,
92
- } ) ,
93
- ) ;
94
- }
76
+ res . writeHead ( 500 ) . end ( ) ;
95
77
}
96
78
} ;
97
79
}
Original file line number Diff line number Diff line change @@ -43,7 +43,6 @@ export type HandlerOptions<Context extends OperationContext = undefined> =
43
43
export function createHandler < Context extends OperationContext = undefined > (
44
44
options : HandlerOptions < Context > ,
45
45
) : RouteHandler {
46
- const isProd = process . env . NODE_ENV === 'production' ;
47
46
const handle = createRawHandler ( options ) ;
48
47
return async function requestListener ( req , reply ) {
49
48
try {
@@ -69,23 +68,7 @@ export function createHandler<Context extends OperationContext = undefined>(
69
68
'Please check your implementation.' ,
70
69
err ,
71
70
) ;
72
- if ( isProd ) {
73
- reply . status ( 500 ) . send ( ) ;
74
- } else {
75
- reply
76
- . status ( 500 )
77
- . header ( 'content-type' , 'application/json; charset=utf-8' )
78
- . send ( {
79
- errors : [
80
- err instanceof Error
81
- ? {
82
- message : err . message ,
83
- stack : err . stack ,
84
- }
85
- : err ,
86
- ] ,
87
- } ) ;
88
- }
71
+ reply . status ( 500 ) . send ( ) ;
89
72
}
90
73
} ;
91
74
}
Original file line number Diff line number Diff line change @@ -55,7 +55,6 @@ export function createHandler<Context extends OperationContext = undefined>(
55
55
options : HandlerOptions < Context > ,
56
56
reqCtx : Partial < FetchAPI > = { } ,
57
57
) : ( req : Request ) => Promise < Response > {
58
- const isProd = process . env . NODE_ENV === 'production' ;
59
58
const api : FetchAPI = {
60
59
Response : reqCtx . Response || Response ,
61
60
TextEncoder : reqCtx . TextEncoder || TextEncoder ,
@@ -81,28 +80,7 @@ export function createHandler<Context extends OperationContext = undefined>(
81
80
'Please check your implementation.' ,
82
81
err ,
83
82
) ;
84
- if ( isProd ) {
85
- return new api . Response ( null , { status : 500 } ) ;
86
- } else {
87
- return new api . Response (
88
- JSON . stringify ( {
89
- errors : [
90
- err instanceof Error
91
- ? {
92
- message : err . message ,
93
- stack : err . stack ,
94
- }
95
- : err ,
96
- ] ,
97
- } ) ,
98
- {
99
- status : 500 ,
100
- headers : {
101
- 'content-type' : 'application/json; charset=utf-8' ,
102
- } ,
103
- } ,
104
- ) ;
105
- }
83
+ return new api . Response ( null , { status : 500 } ) ;
106
84
}
107
85
} ;
108
86
}
Original file line number Diff line number Diff line change @@ -42,7 +42,6 @@ export type HandlerOptions<Context extends OperationContext = undefined> =
42
42
export function createHandler < Context extends OperationContext = undefined > (
43
43
options : HandlerOptions < Context > ,
44
44
) : ( req : IncomingMessage , res : ServerResponse ) => Promise < void > {
45
- const isProd = process . env . NODE_ENV === 'production' ;
46
45
const handle = createRawHandler ( options ) ;
47
46
return async function requestListener ( req , res ) {
48
47
try {
@@ -74,24 +73,7 @@ export function createHandler<Context extends OperationContext = undefined>(
74
73
'Please check your implementation.' ,
75
74
err ,
76
75
) ;
77
- if ( isProd ) {
78
- res . writeHead ( 500 ) . end ( ) ;
79
- } else {
80
- res
81
- . writeHead ( 500 , { 'content-type' : 'application/json; charset=utf-8' } )
82
- . end (
83
- JSON . stringify ( {
84
- errors : [
85
- err instanceof Error
86
- ? {
87
- message : err . message ,
88
- stack : err . stack ,
89
- }
90
- : err ,
91
- ] ,
92
- } ) ,
93
- ) ;
94
- }
76
+ res . writeHead ( 500 ) . end ( ) ;
95
77
}
96
78
} ;
97
79
}
Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ export type HandlerOptions<Context extends OperationContext = undefined> =
54
54
export function createHandler < Context extends OperationContext = undefined > (
55
55
options : HandlerOptions < Context > ,
56
56
) : ( req : Http2ServerRequest , res : Http2ServerResponse ) => Promise < void > {
57
- const isProd = process . env . NODE_ENV === 'production' ;
58
57
const handle = createRawHandler ( options ) ;
59
58
return async function requestListener ( req , res ) {
60
59
try {
@@ -91,24 +90,7 @@ export function createHandler<Context extends OperationContext = undefined>(
91
90
'Please check your implementation.' ,
92
91
err ,
93
92
) ;
94
- if ( isProd ) {
95
- res . writeHead ( 500 ) . end ( ) ;
96
- } else {
97
- res
98
- . writeHead ( 500 , { 'content-type' : 'application/json; charset=utf-8' } )
99
- . end (
100
- JSON . stringify ( {
101
- errors : [
102
- err instanceof Error
103
- ? {
104
- message : err . message ,
105
- stack : err . stack ,
106
- }
107
- : err ,
108
- ] ,
109
- } ) ,
110
- ) ;
111
- }
93
+ res . writeHead ( 500 ) . end ( ) ;
112
94
}
113
95
} ;
114
96
}
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ export type HandlerOptions<Context extends OperationContext = undefined> =
45
45
export function createHandler < Context extends OperationContext = undefined > (
46
46
options : HandlerOptions < Context > ,
47
47
) : Middleware {
48
- const isProd = process . env . NODE_ENV === 'production' ;
49
48
const handle = createRawHandler ( options ) ;
50
49
return async function requestListener ( ctx ) {
51
50
try {
@@ -84,19 +83,6 @@ export function createHandler<Context extends OperationContext = undefined>(
84
83
err ,
85
84
) ;
86
85
ctx . response . status = 500 ;
87
- if ( ! isProd ) {
88
- ctx . response . set ( 'content-type' , 'application/json; charset=utf-8' ) ;
89
- ctx . body = {
90
- errors : [
91
- err instanceof Error
92
- ? {
93
- message : err . message ,
94
- stack : err . stack ,
95
- }
96
- : err ,
97
- ] ,
98
- } ;
99
- }
100
86
}
101
87
} ;
102
88
}
You can’t perform that action at this time.
0 commit comments