<commit_before>import {Context, HttpRequest} from "@azure/functions";
import {Host, Log, LogLevel} from "jovo-core";

const AZURE_FUNCTION_APPENDER_NAME = 'azureFunction';

export class AzureFunction implements Host {
    headers: {[key: string]: string};
    hasWriteFileAccess = false;
    req: HttpRequest;
    context: Context;
    $request: any; // tslint:disable-line

    /**
     * Constructs an AzureFunction host object to handle an incoming request.
     * 
     * @param context Azure Fuctions context object
     * @param req Azure Functions HTTP request object
     * @param contextLogLevel Minimum log level to send to the context logger
     */
    constructor(context: Context, req: HttpRequest, contextLogLevel: LogLevel = LogLevel.DEBUG) {
        this.req = req;
        this.context = context;
        this.headers = req.headers;
        this.$request = req.body;

        // ensure the context log appender has been added to Log
        AzureFunction.addContextLogger(contextLogLevel);
    }

    getRequestObject() {
        return this.$request;
    }

    setResponse(obj: any) { // tslint:disable-line
        return new Promise<void>((resolve) => {
            this.context.res = {
                headers: {
                    'Content-Type': 'application/json',
                },
                statusCode: 200,
                body: obj,
            };
            this.context.done();
            resolve();
        });
    }

    fail(error: Error) { // tslint:disable-line
        if (!this.context.res.statusCode) {
            const responseObj: any = { // tslint:disable-line
                code: 500,
                msg: error.message,
            };

            if (process.env.NODE_ENV === 'production') {
                responseObj.stack = error.stack;
            }

            this.context.res = {
                headers: {
                    'Content-Type': 'application/json',
                },
                statusCode: 500,<commit_msg>Fixing compile error caused by recently merged code<commit_after>import {Context, HttpRequest} from "@azure/functions";
import {Host, JovoResponse, Log, LogLevel} from "jovo-core";

const AZURE_FUNCTION_APPENDER_NAME = 'azureFunction';

export class AzureFunction implements Host {
    headers: {[key: string]: string};
    hasWriteFileAccess = false;
    req: HttpRequest;
    context: Context;
    $request: any; // tslint:disable-line

    /**
     * Constructs an AzureFunction host object to handle an incoming request.
     * 
     * @param context Azure Fuctions context object
     * @param req Azure Functions HTTP request object
     * @param contextLogLevel Minimum log level to send to the context logger
     */
    constructor(context: Context, req: HttpRequest, contextLogLevel: LogLevel = LogLevel.DEBUG) {
        this.req = req;
        this.context = context;
        this.headers = req.headers;
        this.$request = req.body;

        // ensure the context log appender has been added to Log
        AzureFunction.addContextLogger(contextLogLevel);
    }

    getRequestObject() {
        return this.$request;
    }

    setResponse(obj: JovoResponse) {
        return new Promise<void>((resolve) => {
            this.context.res = {
                headers: {
                    'Content-Type': 'application/json',
                },
                statusCode: 200,
                body: obj,
            };
            this.context.done();
            resolve();
        });
    }

    fail(error: Error) {
        if (!this.context.res) {
            const responseObj: any = { // tslint:disable-line
                code: 500,
                msg: error.message,
            };

            if (process.env.NODE_ENV === 'production') {
                responseObj.stack = error.stack;
            }

            this.context.res = {
                headers: {
                    'Content-Type': 'application/json',
                },
                statusCode: 500,
{'fraction_non_alphanumeric': 0.10320641282565131, 'fraction_numerical': 0.0045090180360721445, 'mean_word_length': 1.8279036827195467, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1548089', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1019, 'n_words': 275}