{"size": 1003, "ext": "js", "max_stars_repo_path": "src/index.js", "max_stars_repo_name": "zhestkov/fio", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/index.js", "max_issues_repo_name": "zhestkov/fio", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/index.js", "max_forks_repo_name": "zhestkov/fio", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.2888888889, "max_line_length": 73, "alphanum_fraction": 0.5413758724}
var express = require('express');
var cors = require('cors');
var app = express();

app.use(cors());

app.get('/', function (req, res) {
  var fullname = req.query.fullname ? req.query.fullname : undefined;
  var names = [];
  if (fullname != undefined) {
    var re = new RegExp('[0-9]+');
    if (re.test(fullname)) {
      res.status(200).send('Invalid fullname');
      return;
    }
    names = fullname.split(' ');



    switch (names.length) {
      case 1:
        res.status(200).send(fullname);
        break;
      case 2:
        res.status(200).send(names[1] + ' ' + names[0].charAt(0) + '.');
        break;
      case 3:
        res.status(200).send(names[2] + ' ' + names[0].charAt(0) + '. ' +
      names[1].charAt(0) + '.');
        break;
      default:
        res.status(200).send('Invalid fullname');
        break;
    }
  }
  else {
    res.status(200).send('Invalid fullname');
  }

});

app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});
