'use strict';

/**
 * Module dependencies.
 */
var attestmentsPolicy = require('../policies/attestments.server.policy'),
  attestments = require('../controllers/attestments.server.controller');

module.exports = function (app) {
  // Attestments collection routes
  app.route('/api/attestments').all(attestmentsPolicy.isAllowed)
    .get(attestments.list)
    .post(attestments.create);

  // Single attestment routes
  app.route('/api/attestments/:attestmentId').all(attestmentsPolicy.isAllowed)
    .get(attestments.read)
    .put(attestments.update)
    .put(attestments.addStatement)
    .delete(attestments.delete);

  // Finish by binding the attestment middleware
  app.param('attestmentId', attestments.attestmentByID);
};
