{"size": 1154, "ext": "js", "max_stars_repo_path": "lib/router.js", "max_stars_repo_name": "dstegen/dds-familychat", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/router.js", "max_issues_repo_name": "dstegen/dds-familychat", "max_issues_repo_issues_event_min_datetime": "2021-04-20T17:37:42.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-20T17:37:42.000Z", "max_forks_repo_path": "lib/router.js", "max_forks_repo_name": "dstegen/dds-familychat", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 29.5897435897, "max_line_length": 199, "alphanum_fraction": 0.6551126516}
/*!
 * lib/router.js
 * dds-familychat (https://github.com/dstegen/dds-familychat)
 * Copyright 2020 Daniel Stegen <info@danielstegen.de>
 * Licensed under MIT (https://github.com/dstegen/dds-familychat/blob/master/LICENSE)
 */

'use strict';

// Required modules
const { deliver } = require('webapputils-ds');
const {webView, login, logout, chatView, updateUser } = require('./controller');

function router (request, response, wss, wsport) {
  let route = request.url.substr(1).split('?')[0];
  if (request.url.includes('media') || request.url.includes('myfamily') || request.url.includes('node_modules') || request.url.includes('public') || request.url.includes('favicon')) route = 'static';
  switch (route) {
    case 'static':
      deliver(request, response);
      break;
    case 'login':
      login(request, response, wss);
      break;
    case 'logout':
      logout(request, response, wss);
      break;
    case 'chat':
      chatView(request, response, wss);
      break;
    case 'updateuser':
      updateUser(request, response);
      break;
    default:
      webView(request, response, wss, wsport);
  }
}

 module.exports = router;
