<commit_before>var config = require('../config/config.js');
var auth = require('../lib/auth');
var service = config.service;
var request = require('request');
var routesUtilities = require('../utilities/routes.js');

module.exports = function (app) {
  app.get('/devices/', function (req, res) {
    res.render('devices', routesUtilities.getRenderObject(req));
  });

  app.get('/devices/json', function (req, res) {
    request({
      url: service.device.url,
      timeout: 30 * 1000,
      strictSSL: false,
      headers: {
        Accept: 'application/json'
      }
    }, function (err, response, resBody) {
      if (err) {
        console.log(err);
        return res.json(503, {
          error: 'cannot retrieve device list from ctlapp-wheezy-temp'
        });
      }
      res.status(response.statusCode).type('application/json');
      return res.send(resBody);
    });
  });
};<commit_msg>Use the new configuration to show proper devices page<commit_after>var config = require('../config/config.js');
var auth = require('../lib/auth');
var service = config.service;
var request = require('request');
var routesUtilities = require('../utilities/routes.js');

module.exports = function (app) {
  app.get('/devices/', function (req, res) {
    switch (service.device_application){
      case 'devices':
        return res.render('devices', routesUtilities.getRenderObject(req));
        break;
      case 'cdb':
        return res.redirect(service.cdb.web_portal_url);
        break;
      default:
        return res.send(404, "No valid devices setting has been found");
    }
  });

  app.get('/devices/json', function (req, res) {
    request({
      url: service.device.url,
      timeout: 30 * 1000,
      strictSSL: false,
      headers: {
        Accept: 'application/json'
      }
    }, function (err, response, resBody) {
      if (err) {
        console.log(err);
        return res.json(503, {
          error: 'cannot retrieve device list from ctlapp-wheezy-temp'
        });
      }
      res.status(response.statusCode).type('application/json');
      return res.send(resBody);
    });
  });
};
{'fraction_non_alphanumeric': 0.15605846298915607, 'fraction_numerical': 0.009900990099009901, 'mean_word_length': 2.7097902097902096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '459693', 'n_tokens_mistral': 648, 'n_tokens_neox': 632, 'n_words': 147}