lib/api.route.handler.js
function processApiCall(resource, operation, requestParams) {
    var service = injector.loadModule(utensils.getCamelCase(resource.name + '.service'));
    var adapterName = resource.adapters.api;

    // remove the keys that start with onBehalfOf
    _.each(requestParams, function (val, key) {
        if (key.indexOf('onBehalfOf') === 0) { delete requestParams[key]; }
    });

    // hack fix for when _id not filled in
    if (requestParams._id === '{_id}') {
        delete requestParams._id;
    }

    // loop through request values and parse json
    for (var key in requestParams) {
        if (requestParams.hasOwnProperty(key)) {
            requestParams[key] = utensils.parseIfJson(requestParams[key]);
        }
    }

    var filters = getFilters(resource.name, adapterName, operation);
    return utensils.chainPromises(filters.before, requestParams)
        .then(function (filteredRequest) {
            requestParams = filteredRequest;
            return service[operation](requestParams);
        })
        .then(function (data) {
            return utensils.chainPromises(filters.after, {
                caller:     requestParams.caller,
                lang:       requestParams.lang,
                resource:   resource,
                inputData:  requestParams.data,
                data:       data
            });
        });
}
function processApiCall(resource, operation, requestParams) {
    var service = injector.loadModule(utensils.getCamelCase(resource.name + '.service'));
    var adapterName = resource.adapters.api;

    // remove the keys that start with onBehalfOf
    _.each(requestParams, function (val, key) {
        if (key.indexOf('onBehalfOf') === 0) { delete requestParams[key]; }
    });

    // hack fix for when _id not filled in
    if (requestParams._id === '{_id}') {
        delete requestParams._id;
    }

    // loop through request values and parse json
    for (var key in requestParams) {
        if (requestParams.hasOwnProperty(key)) {
            requestParams[key] = utensils.parseIfJson(requestParams[key]);
        }
    }

    var filters = getFilters(resource.name, adapterName, operation);
    return utensils.chainPromises(filters.before, requestParams)
        .then(function (filteredRequest) {
            requestParams = filteredRequest;
            return service[operation](requestParams);
        })
        .then(function (data) {
            return utensils.chainPromises(filters.after, {
                caller:     requestParams.caller,
                lang:       requestParams.lang,
                resource:   resource,
                inputData:  requestParams.data,
                data:       data
            });
        });
}
function processApiCall ( resource , operation , requestParams ) { var service = injector . loadModule ( utensils . getCamelCase ( resource . name + '.service' ) ) ; var adapterName = resource . adapters . api ; // remove the keys that start with onBehalfOf _ . each ( requestParams , function ( val , key ) { if ( key . indexOf ( 'onBehalfOf' ) === 0 ) { delete requestParams [ key ] ; } } ) ; // hack fix for when _id not filled in if ( requestParams . _id === '{_id}' ) { delete requestParams . _id ; } // loop through request values and parse json for ( var key in requestParams ) { if ( requestParams . hasOwnProperty ( key ) ) { requestParams [ key ] = utensils . parseIfJson ( requestParams [ key ] ) ; } } var filters = getFilters ( resource . name , adapterName , operation ) ; return utensils . chainPromises ( filters . before , requestParams ) . then ( function ( filteredRequest ) { requestParams = filteredRequest ; return service [ operation ] ( requestParams ) ; } ) . then ( function ( data ) { return utensils . chainPromises ( filters . after , { caller : requestParams . caller , lang : requestParams . lang , resource : resource , inputData : requestParams . data , data : data } ) ; } ) ; }
Process an API call. This method is called from the server plugin. Basically, the server
plugin is in charge of taking the API request initially and translating the input values
from the web framework specific format to the pancakes format. Then the server plugin
calls this method with the generic pancancakes values.

@param resource
@param operation
@param requestParams
Process an API call . This method is called from the server plugin . Basically the server plugin is in charge of taking the API request initially and translating the input values from the web framework specific format to the pancakes format . Then the server plugin calls this method with the generic pancancakes values .