core/api/index.js
function (req, res, parseObj) {
    var data = {};
    var body = req.body;
    var reqID = body.id || req.query.id;
    var reqSections = body.sections || req.query.sections;
    var sections = reqSections ? reqSections.split(',') : undefined;
    var parsedData = parseObj;

    var msgDataNotFound = 'API: HTML data not found, please sync API or run PhantomJS parser.';

    if (reqID) {
        var responseData = '';

        if (reqSections) {
            responseData = parsedData.getBySection(reqID, sections);
        } else {
            responseData = parsedData.getByID(reqID);
        }

        if (responseData && typeof responseData === 'object') {
            res.status(config.statusCodes.OK).json(responseData);
        } else {
            if (typeof responseData === 'undefined') console.warn(msgDataNotFound);

            res.status(config.statusCodes.notFound).json({
                message: "id and requested sections not found"
            });
        }
    } else {
        data = parsedData.getAll();

        if (data) {
            res.status(config.statusCodes.OK).json(data);
        } else {
            console.warn(msgDataNotFound);

            res.status(config.statusCodes.notFound).json({
                message: "data not found"
            });
        }
    }
}
function (req, res, parseObj) {
    var data = {};
    var body = req.body;
    var reqID = body.id || req.query.id;
    var reqSections = body.sections || req.query.sections;
    var sections = reqSections ? reqSections.split(',') : undefined;
    var parsedData = parseObj;

    var msgDataNotFound = 'API: HTML data not found, please sync API or run PhantomJS parser.';

    if (reqID) {
        var responseData = '';

        if (reqSections) {
            responseData = parsedData.getBySection(reqID, sections);
        } else {
            responseData = parsedData.getByID(reqID);
        }

        if (responseData && typeof responseData === 'object') {
            res.status(config.statusCodes.OK).json(responseData);
        } else {
            if (typeof responseData === 'undefined') console.warn(msgDataNotFound);

            res.status(config.statusCodes.notFound).json({
                message: "id and requested sections not found"
            });
        }
    } else {
        data = parsedData.getAll();

        if (data) {
            res.status(config.statusCodes.OK).json(data);
        } else {
            console.warn(msgDataNotFound);

            res.status(config.statusCodes.notFound).json({
                message: "data not found"
            });
        }
    }
}
function ( req , res , parseObj ) { var data = { } ; var body = req . body ; var reqID = body . id || req . query . id ; var reqSections = body . sections || req . query . sections ; var sections = reqSections ? reqSections . split ( ',' ) : undefined ; var parsedData = parseObj ; var msgDataNotFound = 'API: HTML data not found, please sync API or run PhantomJS parser.' ; if ( reqID ) { var responseData = '' ; if ( reqSections ) { responseData = parsedData . getBySection ( reqID , sections ) ; } else { responseData = parsedData . getByID ( reqID ) ; } if ( responseData && typeof responseData === 'object' ) { res . status ( config . statusCodes . OK ) . json ( responseData ) ; } else { if ( typeof responseData === 'undefined' ) console . warn ( msgDataNotFound ) ; res . status ( config . statusCodes . notFound ) . json ( { message : "id and requested sections not found" } ) ; } } else { data = parsedData . getAll ( ) ; if ( data ) { res . status ( config . statusCodes . OK ) . json ( data ) ; } else { console . warn ( msgDataNotFound ) ; res . status ( config . statusCodes . notFound ) . json ( { message : "data not found" } ) ; } } }
getHTML REST api processor

@param {Object} req - express request
@param {Object} res - express response
@param {Object} parseObj - initiated parseData instance

Writes result to res object
getHTML REST api processor