All files / bintra/controllers Queue.js

91.66% Statements 11/12
100% Branches 1/1
66.66% Functions 2/3
91.66% Lines 11/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                  1x 1x 1x   1x 1x 1x 1x             1x 1x   1x   1x            
'use strict';
 
/**
 * API controller for queue handling stuff.
 * @module controllers/queue
 * @license MIT
 * @author Kai KRETSCHMANN <kai@kretschmann.consulting>
 */
 
const utils = require('../utils/writer.js');
const eventEmitter = require('../utils/eventer').em;
const QueueService = require('../service/QueueService');
 
const log4js = require('log4js');
const logger = log4js.getLogger();
logger.level = process.env.LOGLEVEL || /* istanbul ignore next */ 'warn'; // LCOV_EXCL_LINE
const EVENTNAME = 'apihit';
 
/**
 * List all queues and entry counts.
 * @function listQueues
 * @public
 */
module.exports.listQueues = function listQueues (req, res, _next) {
  eventEmitter.emit(EVENTNAME, req);
 
  QueueService.listQueues()
    .then(function (payload) {
      utils.writeJson(res, payload, 200);
    })
    .catch(function (payload) {
      utils.writeJson(res, payload, 400);
    });
};