functionality for managing carts, creating orders and products - #1
functionality for managing carts, creating orders and products#1kandalova wants to merge 19 commits into
Conversation
| // res.status(201).send(cart); | ||
| // }); | ||
|
|
||
| cartRouter.get("/", async (req:Request, res:Response, next:NextFunction) => { |
There was a problem hiding this comment.
В HTTP, метод GET предназначен для получения данных и не должен использоваться для создания сущностей в базе данных. Это соответствует стандартам и лучшим практикам проектирования RESTful API.
| const cartRouter = express.Router(); | ||
| cartRouter.use(express.json()); | ||
|
|
||
| // cartRouter.post("/", async (req:Request, res:Response, next:NextFunction) => { |
| } | ||
|
|
||
| export const getResponseError = async (message:string):Promise<IResponseError>=>{ | ||
| return { |
There was a problem hiding this comment.
Что-то отступы во всех файлах отличаются. Наверно формат space не зафиксирован в VS
There was a problem hiding this comment.
Добавила авто-форматирование + отформатировала все файлы
| try { | ||
| return await prom; | ||
| } catch (error) { | ||
| console.log('HERE') |
There was a problem hiding this comment.
давай подчистим код от дебажных console.log
| return response; | ||
| } | ||
|
|
||
| export const getDeleteCartResponse = (): IDeleteCartResponse => { |
There was a problem hiding this comment.
почему решила выделить в отдельную функцию ?
There was a problem hiding this comment.
Подумала, что формат ответа может переиспользоваться или поменяться в будущем. Показалось, так легче будет править
| import { productDB } from ".."; | ||
| import { IProduct } from "../scheme/ProductScheme"; | ||
|
|
||
| export const getTotalPrice = (products: IProduct[]):number =>{ |
There was a problem hiding this comment.
Упс, забытый дубликат, удалила
| import { ResponseError, getForbidenError, getUnauthorizedError } from "./utils/errors.ts"; | ||
| import { getResponseError } from "./utils/utils.ts"; | ||
|
|
||
| export const userDB = users; |
There was a problem hiding this comment.
Я их один раз импортирую из файла при старте приложения и потом на все приложение экспортирую, а-ля глобальные переменные, лучше поменять?
There was a problem hiding this comment.
вынесла в отдельный модуль (т.к. ES6 modules по дефолту синглтоны)
…/node-mentoring-shop into task_6_shop_express.js


No description provided.