import express from 'express';
import _ from 'lodash';
import cors from 'cors';

const app = express();
app.use(cors());
app.get('/', function (req, res) {
  const a = _.get(req.query, 'a', 0);
  const b = _.get(req.query, 'b', 0);
  res.send(200, Number(a) + Number(b));
});

app.get('/name', function (req, res) {
  console.log(_.get(req.query, 'fullname', ''));
  const fullName = _.get(req.query, 'fullname', '');
  const wrongSymbols = fullName.match(/[\d_\/]/);
  const match = _.get(req.query, 'fullname', '').match(/([\S]+)\s*([\S]*)\s*([\S]*)\s*(.*)/i);
  const parts = _.chain(match).drop().compact().value();

  if (fullName.length === 0 || wrongSymbols !== null || parts.length > 3) {
    res.send(200, 'Invalid fullname');
    return;
  }
  let shortName = '';
  shortName += _.capitalize(_.last(parts).toLowerCase());
  if (parts.length > 1) {
    shortName += _.chain(parts).dropRight().map(function(string) {
      const symbol = _.capitalize(string.charAt(0));
      return  ` ${symbol}.`;
    }).join('');
  }

  res.send(200, shortName);
});

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

@@ -313,57 +313,8 @@
 ) %7B%0A
-  console.log(_.get(req.query, 'fullname', ''));%0A
   co
@@ -684,20 +684,8 @@
 ');%0A
-    return;%0A
   %7D%0A
@@ -990,24 +990,399 @@
 Name);%0A%7D);%0A%0A
+app.get('/task3', function (req, res) %7B%0A  const usernameUrl = _.get(req.query, 'username', '');%0A  const match = usernameUrl%0A    .match(/(?:https:%7Chttp:)?(?:%5C/%5C/)?(?:%5Ba-z0-9%5C.-%5D+%5C.%5Ba-z0-9-%5D+)?%5C/?@?(%5Ba-z%5C.%5C_%5D+)/i);%0A  const username = _.chain(match).drop().value();%0A  if (username.length === 0) %7B%0A    res.send(200, 'Invalid fullname');%0A  %7D%0A  res.send(200, '@' + username);%0A%7D);%0A%0A
 app.listen(5
@@ -1445,17 +1445,17 @@
 on port 
-3
+5
 000!');%0A

task3 done