Open
Conversation
ArtemNikolaev
suggested changes
Oct 4, 2021
ArtemNikolaev
left a comment
There was a problem hiding this comment.
Хорошая работа, но есть некоторые архитектурные ошибки. Спрашивай если что-то будет непонятно.
request/protocol.js
Outdated
| const http = require("http"); | ||
| const https = require("https"); | ||
|
|
||
| const getProtocol = (url) => { |
There was a problem hiding this comment.
протокола в урле может и не быть :-)
request/get.js
Outdated
|
|
||
| const get = (urlString) => { | ||
| return new Promise((resolve, reject) => { | ||
| try { |
There was a problem hiding this comment.
try catch тут не нужен
потому как ошибку .get ты уже отлавливаешь, а ошибку .on('error') ты так не поймаешь
request/get.js
Outdated
| try { | ||
| const url = new URL(urlString); | ||
| const protocol = getProtocol(url); | ||
| protocol.get(url, (response) => { |
There was a problem hiding this comment.
в данном месте идет сильное сцепление getProtocol и текущего кода , потому как не посмотрев внутрь не поймешь что это за метод get такой
вопрос как лучше сделать достаточно холиварный, я бы реализовал это через алиас
const requestAlias = isHttp(url) ? http : https;
requestAlias.get()
так это хотя бы в одном месте находится и не надо куда-либо ходить за ответом
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.