Skip to content

functionality for managing carts, creating orders and products - #1

Open
kandalova wants to merge 19 commits into
developfrom
task_6_shop_express.js
Open

functionality for managing carts, creating orders and products#1
kandalova wants to merge 19 commits into
developfrom
task_6_shop_express.js

Conversation

@kandalova

Copy link
Copy Markdown
Owner

No description provided.

@kandalova
kandalova marked this pull request as ready for review October 6, 2023 18:43
Comment thread src/controller/cart.controller.ts Outdated
// res.status(201).send(cart);
// });

cartRouter.get("/", async (req:Request, res:Response, next:NextFunction) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

В HTTP, метод GET предназначен для получения данных и не должен использоваться для создания сущностей в базе данных. Это соответствует стандартам и лучшим практикам проектирования RESTful API.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Я от задания отталкивалась 😄
image

const cartRouter = express.Router();
cartRouter.use(express.json());

// cartRouter.post("/", async (req:Request, res:Response, next:NextFunction) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

почему закомментила post ?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Сначала он был в описании апи, потом пропал (можно по коммитам в репо задания увидеть)
Решила закоментить поэтому
image

Comment thread src/utils/utils.ts
}

export const getResponseError = async (message:string):Promise<IResponseError>=>{
return {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Что-то отступы во всех файлах отличаются. Наверно формат space не зафиксирован в VS

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Добавила авто-форматирование + отформатировала все файлы

Comment thread src/utils/utils.ts Outdated
try {
return await prom;
} catch (error) {
console.log('HERE')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

давай подчистим код от дебажных console.log

Comment thread src/utils/cartUtils.ts
return response;
}

export const getDeleteCartResponse = (): IDeleteCartResponse => {

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
Owner Author

Choose a reason for hiding this comment

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

Подумала, что формат ответа может переиспользоваться или поменяться в будущем. Показалось, так легче будет править

Comment thread src/service/product.service.ts Outdated
import { productDB } from "..";
import { IProduct } from "../scheme/ProductScheme";

export const getTotalPrice = (products: IProduct[]):number =>{

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
Owner Author

Choose a reason for hiding this comment

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

Упс, забытый дубликат, удалила

Comment thread src/index.ts Outdated
import { ResponseError, getForbidenError, getUnauthorizedError } from "./utils/errors.ts";
import { getResponseError } from "./utils/utils.ts";

export const userDB = users;

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
Owner Author

Choose a reason for hiding this comment

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

Я их один раз импортирую из файла при старте приложения и потом на все приложение экспортирую, а-ля глобальные переменные, лучше поменять?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

вынесла в отдельный модуль (т.к. ES6 modules по дефолту синглтоны)

@kandalova kandalova changed the title Two working methods functionality for managing carts, creating orders and products Oct 13, 2023
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