{"size": 983, "ext": "js", "max_stars_repo_path": "controllers/contract.js", "max_stars_repo_name": "cedwards-reisys/nexus-api", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "controllers/contract.js", "max_issues_repo_name": "cedwards-reisys/nexus-api", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "controllers/contract.js", "max_forks_repo_name": "cedwards-reisys/nexus-api", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.7878787879, "max_line_length": 224, "alphanum_fraction": 0.6978636826}
/*
 * nexus-api
 * https://github.com/cedwards-reisys/nexus-api
 *
 * Copyright (c) 2015 Chris Edwards
 * Licensed under the MIT license.
 */

'use strict';

var logger = require('../utils/logger');
var ApiController = require('./api');

var apiController = new ApiController({index: 'contracts', dateFields:['signeddate','effectivedate','currentcompletiondate','ultimatecompletiondate','lastdatetoorder','registrationdate','renewaldate','last_modified_date']});

var ContractController = function () {
    this.ES_INDEX = 'contracts';
};

ContractController.prototype.getIndex = function (request,reply) {
    try {
        var params = apiController.getParams(request.query);
        var es_params = apiController.getElasticsearchParams(params);
        var result = apiController.search(params,es_params);
        reply(result);
    } catch (e) {
        logger.error(e);
        reply(apiController.error(e.message, e.code));
    }
};

module.exports = new ContractController();
