Skip to content

Практическая работа №4#4

Open
rick-nice wants to merge 14 commits into
client-server-appfrom
client-server-app-done
Open

Практическая работа №4#4
rick-nice wants to merge 14 commits into
client-server-appfrom
client-server-app-done

Conversation

@rick-nice

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/client/Controller.js

async getAll() {
try {
const response = await window.fetch(URL.RECIPES);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

просто используй fetch вместо window.fetch.

Comment thread src/client/View.js

handleShowAll(e) {
e.preventDefault();
while (this.recipeList.lastChild) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

вынеси в утилку.

Comment thread src/client/View.js
this.emit(EVENTS.DELETE, { id });
}

addRecipe({ name, _id, ingredients: ingr, instruction: instr, favorite }) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

слишком большой метод, надо было разнести на мелкии.

Comment thread src/server/config.js
@@ -0,0 +1,6 @@
import 'dotenv/config';

export const { PORT } = process.env;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

зачем экспорт каждого по отдельности?

export const { PORT, DATABASE_URL, DB_USER , DB_PASSWORD   } = process.env;

Comment thread src/server/server.js

// прокидываем models в request\response цикл

app.use(async (req, res, next) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

зачем async.

Comment thread src/server/server.js
// прокидываем models в request\response цикл

app.use(async (req, res, next) => {
req.context = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

req.context не вижу профита в этом, почему не импортировать модели в нужное место, чем к каждому запросу их прокидывать, там где они даже могут быть и не нужны.

Comment thread src/client/View.js
this.recipeList.removeChild(card.parentNode);
}

addToFavorites(card, id, img) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

можно было бы вынести в метод и воспользоваться как для addToFavorites так и для delFromFavorites

Comment thread src/client/View.js
handleCreateRecipe(e) {
e.preventDefault();
const d = document;
const name = d.getElementById('name').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.

деструктуризация, получение value.

Comment thread src/client/View.js

showEditRecipeModal({ target }) {
const d = document;
const card = target.parentNode.parentNode;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

много где повторяется target.parentNode.parentNode, можно было написать утил функцию которая рекурсивно достаёт и передавал параметр как далеко опускаться в рекурсии.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants