@@ -13,7 +13,13 @@ import { callBugListeners } from './runTelefunc/onBug.js'
1313import { applyShield } from './runTelefunc/applyShield.js'
1414import { findTelefunction } from './runTelefunc/findTelefunction.js'
1515import { getServerConfig } from './serverConfig.js'
16- import { STATUS_CODE_ABORT , STATUS_CODE_SHIELD_VALIDATION_ERROR } from '../../shared/constants.js'
16+ import {
17+ STATUS_CODE_THROW_ABORT ,
18+ STATUS_CODE_SHIELD_VALIDATION_ERROR ,
19+ STATUS_CODE_INTERNAL_SERVER_ERROR ,
20+ STATUS_CODE_MALFORMED_REQUEST ,
21+ STATUS_CODE_SUCCESS ,
22+ } from '../../shared/constants.js'
1723
1824/** The HTTP Response of a telefunction remote call HTTP Request */
1925type HttpResponse = {
@@ -46,23 +52,23 @@ const shieldValidationError = {
4652// - The Telefunc code threw an error (i.e. Telefunc has a bug).
4753const serverError = {
4854 // TODO dedupe
49- statusCode : 500 as const , // "Internal Server Error"
55+ statusCode : STATUS_CODE_INTERNAL_SERVER_ERROR ,
5056 // TODO dedupe
5157 body : 'Internal Server Error' ,
5258 contentType : 'text/plain' as const ,
5359 etag : null ,
54- }
60+ } as const
5561
5662// HTTP Response for:
5763// - Some non-telefunc client makes a malformed HTTP request.
5864// - The telefunction couldn't be found.
5965const malformedRequest = {
60- statusCode : 400 as const , // "Bad Request"
66+ statusCode : STATUS_CODE_MALFORMED_REQUEST ,
6167 // TODO dedupe
6268 body : 'Malformed Telefunc Request' ,
6369 contentType : 'text/plain' as const ,
6470 etag : null ,
65- }
71+ } as const
6672
6773async function runTelefunc ( runContext : Parameters < typeof runTelefunc_ > [ 0 ] ) : Promise < HttpResponse > {
6874 try {
@@ -174,7 +180,7 @@ async function runTelefunc_(httpRequest: {
174180 // }
175181
176182 return {
177- statusCode : runContext . telefunctionAborted ? STATUS_CODE_ABORT : 200 ,
183+ statusCode : runContext . telefunctionAborted ? STATUS_CODE_THROW_ABORT : STATUS_CODE_SUCCESS ,
178184 body : runContext . httpResponseBody ,
179185 contentType : 'text/plain' ,
180186 // etag: runContext.httpResponseEtag,
0 commit comments