/**
 * This function is just a wrapper that builds the response that api gateway wants
 * TODO:- Probably might be worth adding the right type for allowed status codes
 */
export function respond(statusCode, response, headers, isBase64Encoded) {
    const result = {
        statusCode: statusCode,
        body: JSON.stringify(response),
    };
    /**
     * The next sections parses out single value and multi values headers from headers
     * This makes it easy to send out the response
     */
    const singleValueHeaders = {};
    const multiValueHeaders = {};
    if (headers) {
        Object.keys(headers).forEach(header => {
            const value = headers[header];
            if (Array.isArray(value)) {
                multiValueHeaders[header] = value;
            }
            else {
                singleValueHeaders[header] = value;
            }
        });
    }
    if (Object.keys(singleValueHeaders).length > 0) {
        result.headers = singleValueHeaders;
    }
    if (Object.keys(multiValueHeaders).length > 0) {
        result.multiValueHeaders = multiValueHeaders;
    }
    if (typeof isBase64Encoded === "boolean") {
        result.isBase64Encoded = isBase64Encoded;
    }
    return result;
}
//# sourceMappingURL=api-gateway.js.map