core/api/index.js
function (req, res, parseObj) {
    var data = {};
    var body = req.body;
    var reqID = body.id || req.query.id;
    var cats = body.cats || req.query.cats;
    var reqFilter = body.filter || req.query.filter;
    var reqFilterOut = body.filterOut || req.query.filterOut;
    var parsedData = parseObj;

    var msgDataNotFound = 'API: Specs data not found, please restart the app.';

    if (reqID) {
        var dataByID = parsedData.getByID(reqID);

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

            res.status(config.statusCodes.notFound).json({
                message: "id not found"
            });
        }

    } else if (reqFilter || reqFilterOut) {
        var dataFiltered = parsedData.getFilteredData({
            filter: reqFilter,
            filterOut: reqFilterOut
        });

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

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

        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 cats = body.cats || req.query.cats;
    var reqFilter = body.filter || req.query.filter;
    var reqFilterOut = body.filterOut || req.query.filterOut;
    var parsedData = parseObj;

    var msgDataNotFound = 'API: Specs data not found, please restart the app.';

    if (reqID) {
        var dataByID = parsedData.getByID(reqID);

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

            res.status(config.statusCodes.notFound).json({
                message: "id not found"
            });
        }

    } else if (reqFilter || reqFilterOut) {
        var dataFiltered = parsedData.getFilteredData({
            filter: reqFilter,
            filterOut: reqFilterOut
        });

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

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

        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 cats = body . cats || req . query . cats ; var reqFilter = body . filter || req . query . filter ; var reqFilterOut = body . filterOut || req . query . filterOut ; var parsedData = parseObj ; var msgDataNotFound = 'API: Specs data not found, please restart the app.' ; if ( reqID ) { var dataByID = parsedData . getByID ( reqID ) ; if ( dataByID && typeof dataByID === 'object' ) { res . status ( config . statusCodes . OK ) . json ( dataByID ) ; } else { if ( typeof dataByID === 'undefined' ) console . warn ( msgDataNotFound ) ; res . status ( config . statusCodes . notFound ) . json ( { message : "id not found" } ) ; } } else if ( reqFilter || reqFilterOut ) { var dataFiltered = parsedData . getFilteredData ( { filter : reqFilter , filterOut : reqFilterOut } ) ; if ( dataFiltered && typeof dataFiltered === 'object' ) { res . status ( config . statusCodes . OK ) . json ( dataFiltered ) ; } else { console . warn ( msgDataNotFound ) ; res . status ( config . statusCodes . notFound ) . json ( { message : "data not found" } ) ; } } else { data = parsedData . getAll ( cats ) ; if ( data ) { res . status ( config . statusCodes . OK ) . json ( data ) ; } else { console . warn ( msgDataNotFound ) ; res . status ( config . statusCodes . notFound ) . json ( { message : "data not found" } ) ; } } }
getSpecs REST api processor

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

Writes result to res object
getSpecs REST api processor