Skip to content

Нагаев Дмитрий#3

Closed
fng3r wants to merge 8 commits intourfu-2017:masterfrom
fng3r:master
Closed

Нагаев Дмитрий#3
fng3r wants to merge 8 commits intourfu-2017:masterfrom
fng3r:master

Conversation

@fng3r
Copy link
Copy Markdown

@fng3r fng3r commented Dec 5, 2017

No description provided.

@honest-hrundel
Copy link
Copy Markdown

🍅 Пройдено тестов 15 из 18

@honest-hrundel
Copy link
Copy Markdown

🍅 Пройдено тестов 19 из 26

@honest-hrundel
Copy link
Copy Markdown

🍅 Пройдено тестов 19 из 26

@honest-hrundel
Copy link
Copy Markdown

🍏 Пройдено тестов 31 из 31

@honest-hrundel
Copy link
Copy Markdown

@Zhigalov обрати внимание: решено доп. задание

@honest-hrundel
Copy link
Copy Markdown

🍏 Пройдено тестов 31 из 31

@honest-hrundel
Copy link
Copy Markdown

@Zhigalov обрати внимание: решено доп. задание

Copy link
Copy Markdown

@Zhigalov Zhigalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 хорошо написал!
В некоторых местах мне кажется сложновато, можно упростить.

server-core.js Outdated
app.use(bodyParser.json());

app.get('/messages', (req, res) => {
const query = req.query;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const { query } = req;

Чтобы два раза слово query не писать

}

delete messages[messageId];
res.json({ status: 'ok' });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я обычно в таких случаях не возвращаю ничего в теле ответа
А повзращаю только статус код 204 No Content («нет содержимого»)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это из спеки к таску

Метод удаляет сообщение с заданным id и возвращает { "status": "ok" }.

client-core.js Outdated
function createQueryFrom(args) {
const query = {};

if (args.from) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return ['from', 'to']
    .filter(...)
    .reduce(..., {});

Будет более "расширяемо"

const argparse = require('argparse');
const Forge = require('forge-di').default;

const forge = new Forge();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Расскажи какую проблему решает Forge?
В чем потеряешь, если не будешь его использовать?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Просто было интересно попробовать dic в js.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выглядит как оверхэд.
Ладно бы это популярная библиотека была...

@@ -0,0 +1,23 @@
'use strict';

class CommandsExecutor {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я обычно "стратегию" реализую через объект.
С ним легче работать, минус один уровень абстракции

В чем преимущество твоего решения?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы не сказал, что это "стратегия". Скорее, "команда" в совокупности со множеством команд, CommandsExecutor - "invoker", сервер - "reciever". Но, вообще, да, можно было бы CommandsExecutor представить как объект со свойствами, содержащими команды

formatMessageField('FROM', message.from, colors.red) +
formatMessageField('TO', message.to, colors.red) +
formatMessageField('TEXT', message.text, colors.green, '') +
`${message.edited ? colors.grey('(edited)') : ''}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не консистентно: проверка на verbose через if, а здесь через тернарник

};

function formatMessageField(name, value, nameFormatter, lineEnding = '\n') {
if (!value) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тернарник

query
});

return got(url, { method, body, json: true });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url вроде можно тоже в опции положить

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

44fb961d7706105623f598840ea91fee

package.json Outdated
"got": "8.0.1",
"mocha": "4.0.1",
"nock": "5.5.0",
"querystring": "0.2.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не нашел где эта зависимость используется
всё что не используется лучше убирать, сборка будет быстрее


execute(params) {
return sendRequest(params)
.then(res => res.body.map(m => formatMessage(m, params.verbose)).join('\n\n'));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А что делаешь в случае ошибки? 4XX или 5XX

@honest-hrundel
Copy link
Copy Markdown

🍏 Пройдено тестов 31 из 31

@honest-hrundel
Copy link
Copy Markdown

@Zhigalov обрати внимание: решено доп. задание

@honest-hrundel
Copy link
Copy Markdown

🍏 Пройдено тестов 31 из 31

@honest-hrundel
Copy link
Copy Markdown

@Zhigalov обрати внимание: решено доп. задание

Copy link
Copy Markdown

@Zhigalov Zhigalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Единственное замечание - много лишнего кода, от которого можно избавиться и станет только понятнее. Поскольку дедлайны поджимают - закрываю задачу.

const argparse = require('argparse');
const Forge = require('forge-di').default;

const forge = new Forge();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выглядит как оверхэд.
Ладно бы это популярная библиотека была...

@fng3r
Copy link
Copy Markdown
Author

fng3r commented Dec 12, 2017

@Zhigalov дедлайн в понедельник, вроде, так что можно и поправить

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants