All files / bintra/controllers Queue.js

92.3% Statements 12/13
50% Branches 1/2
66.66% Functions 2/3
92.3% Lines 12/13

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 36 37                  1x 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('CONTROLLERS');
logger.level = process.env.LOGLEVEL_CONTROLLERS || process.env.LOGLEVEL || /* istanbul ignore next */ 'warn';
logger.error(`Local loglevel for CONTROLLERS is ${logger.level}`);
const EVENTNAME = 'apihit';
 
/**
 * List all queues and entry counts.
 * @function listQueues
 * @public
 * @async
 */
module.exports.listQueues = async function listQueues (req, res) {
  eventEmitter.emit(EVENTNAME, req);
 
  QueueService.listQueues()
    .then(function (payload) {
      utils.writeJson(res, payload, 200);
    })
    .catch(function (error) {
      utils.writeJson(res, error, 400);
    });
};