'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _cli = require('../../../../cli');

var route = function route(req, res, next) {
  _cli.abeExtend.hooks.instance.trigger('beforeRoute', req, res, next);
  if (typeof res._header !== 'undefined' && res._header !== null) return;

  var operation = _cli.cmsData.regex.getWorkflowFromOperationsUrl(req.originalUrl);

  var p = _cli.cmsOperations.post.reject(operation.postUrl, req.body.json, operation.workflow);

  p.then(function (result) {
    res.set('Content-Type', 'application/json');
    res.send(JSON.stringify(result));
  }, function (result) {
    res.set('Content-Type', 'application/json');
    res.send(JSON.stringify(result));
  }).catch(function (e) {
    console.error('[ERROR] post-reject.js', e);
  });
};

exports.default = route;