Http.js

function postRequest( request, response, callback ) {
    var queryData = "";
    if ( typeof callback !== 'function' ) return null;

    if ( request.method == 'POST' ) {
        request.on ( 'data', function ( data ) {
            queryData += data;
            if ( queryData.length > 100 ) {
                queryData = "";
                response.writeHead ( 413, {'Content-Type': 'text/plain'}).end ();
                request.connection.destroy ();
            }
        });

        request.on ( 'end', function () {
            response.post = querystring.parse ( queryData );
            console.log('Calling callback');
            callback ();
        });
    } else {
        response.writeHead ( 405, { 'Content-Type': 'text/plain' });
        response.end ();
    }
}

const Http = {
    postRequest
};

module.exports = Http;