<commit_before>var hapi = {};

hapi.HAPI_VERB = {
    get: "getting",
    create: "creating",
    update: "changing",
    delete: "deleting"
};

hapi.makeHAPISuccess = function (HAPI_VERB, resourceType, data) {
    var hapiResponse = {
        "this": "succeeded",
        "by": HAPI_VERB,
        "the": resourceType,
        "with": data
    };

    return hapiResponse;
}

hapi.makeHAPIFailure = function (why, httpErrorCode, apiErrorCode) {
    httpErrorCode = httpErrorCode || 500;

    var hapiResponse = {
        "this": "failed",
        "with": apiErrorCode || httpErrorCode,
        "because": why
    };

    return hapiResponse;
}

function middleware()
{
    function hapiMiddleware(req, res, next) {
        res.sendHAPISuccess = function(HAPI_VERB, resourceType, data)
        {
            res.send(hapi.makeHAPISuccess(HAPI_VERB, resourceType, data));
        }

        res.sendHAPIFailure = function(why, httpErrorCode, apiErrorCode)
        {
            res.send(httpErrorCode || apiErrorCode || 500, hapi.makeHAPIFailure(why, httpErrorCode, apiErrorCode));
        }

        res.sendHAPINotFoundFailure = function()
        {
            res.sendHAPIFailure("we couldn't find this", 404, 404);
        }

        return (next());
    }

    return (hapiMiddleware);
}

hapi.middleware = middleware;

module.exports = hapi;
<commit_msg>Always return 200 HTTP response unless otherwise specified<commit_after>var hapi = {};

hapi.HAPI_VERB = {
    get: "getting",
    create: "creating",
    update: "changing",
    delete: "deleting"
};

hapi.makeHAPISuccess = function (HAPI_VERB, resourceType, data) {
    var hapiResponse = {
        "this": "succeeded",
        "by": HAPI_VERB,
        "the": resourceType,
        "with": data
    };

    return hapiResponse;
}

hapi.makeHAPIFailure = function (why, httpErrorCode, apiErrorCode) {
    httpErrorCode = httpErrorCode || 500;

    var hapiResponse = {
        "this": "failed",
        "with": apiErrorCode || httpErrorCode,
        "because": why
    };

    return hapiResponse;
}

function middleware()
{
    function hapiMiddleware(req, res, next) {
        res.sendHAPISuccess = function(HAPI_VERB, resourceType, data)
        {
            res.send(hapi.makeHAPISuccess(HAPI_VERB, resourceType, data));
        }

        res.sendHAPIFailure = function(why, httpErrorCode, apiErrorCode)
        {
            res.send(httpErrorCode || 200, hapi.makeHAPIFailure(why, httpErrorCode, apiErrorCode));
        }

        res.sendHAPINotFoundFailure = function()
        {
            res.sendHAPIFailure("we couldn't find this", 200, 404);
        }

        return (next());
    }

    return (hapiMiddleware);
}

hapi.middleware = middleware;

module.exports = hapi;

{'fraction_non_alphanumeric': 0.12085911903895158, 'fraction_numerical': 0.009828904259191846, 'mean_word_length': 2.6157894736842104, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, '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': '2661145', 'n_tokens_mistral': 925, 'n_tokens_neox': 893, 'n_words': 178}