import { log } from 'napajs' ; import * as utils from './utils' ; import { ResponseCode , Response } from './response' ; import { RequestContext } from './request-context' ; export async function passThrough ( context ) { return await context . continueExecution ( ) ; } export async function shortCircuit ( context ) { return Promise . resolve ( { responseCode : ResponseCode . Success } ) ; } export async function executeEntryPoint ( context ) { let response = await context . continueExecution ( ) ; response . output = await utils . makePromiseIfNotAlready ( context . entryPoint ( context , context . input ) ) ; return response ; } export async function logRequest ( context ) { log . debug ( JSON . stringify ( context . request ) ) ; return await context . continueExecution ( ) ; } export async function logResponse ( context ) { let response = await context . continueExecution ( ) ; log . debug ( JSON . stringify ( response ) ) ; return response ; } export async function logRequestResponse ( context ) { log . debug ( JSON . stringify ( context . request ) ) ; let response = await context . continueExecution ( ) ; log . debug ( JSON . stringify ( response ) ) ; return response ; } export async function finalizeResponse ( context ) { let response = await context . continueExecution ( ) ; if ( context . controlFlags . debug ) { response . debugInfo = context . debugger . getOutput ( ) ; } if ( context . controlFlags . perf ) { response . perfInfo = context . perf . data ; } return response ; }