๋ชฉ๋ก๐ฉ๐ป ๋ฐฑ์๋(Back-End)/Node js (108)
๐ ๊ณต๋ถํ๋ ์ง์ง์ํ์นด๋ ์ฒ์์ด์ง?
=> Node.js E-Commerce App with REST API: Let's Build a Real-Life Example! ๐ท Wishlist ์กฐํํ๊ธฐ ๐ท address ์ถ๊ฐํ๊ธฐ ๐ท Cart์ ์ํ ๋ฃ๊ธฐ ๐ท Cart์ ์ํ ์กฐํํ๊ธฐ ๐ท Cart ์ํ ์ญ์ ํ๊ธฐ (๋น ์ฅ๋ฐ๊ตฌ๋) ๐ท Coupon ์ ์ฉํ๊ธฐ
=> Node.js E-Commerce App with REST API: Let's Build a Real-Life Example! ๐ท Cloudinary : ์น์ฌ์ดํธ ๋ฐ ๋ชจ๋ฐ์ผ ์ ํ๋ฆฌ์ผ์ด์ ์ฉ ์ด๋ฏธ์ง์ ๋์์์ ๊ด๋ฆฌ, ์ต์ ํ, ์ ์กํ ์ ์๋ ํ๋ซํผ์ ์ ๊ณตํ๋ ํด๋ผ์ฐ๋ ๊ธฐ๋ฐ ์๋น์ค : ์๋ฒ์ ์ด๋ฏธ์ง๋ฅผ ์ ์ฅํ์ง ์๊ณ storage์ ๋ฐ๋ก ์ด๋ฏธ์ง ํ์ผ์ ์ ์ฅํ๊ณ ์ ํจ npm i multer sharp cloudinary product ๋ฒ์ ๊ณผ ๊ฐ์!
=> Node.js E-Commerce App with REST API: Let's Build a Real-Life Example! ๐ท Cloudinary : ์น์ฌ์ดํธ ๋ฐ ๋ชจ๋ฐ์ผ ์ ํ๋ฆฌ์ผ์ด์ ์ฉ ์ด๋ฏธ์ง์ ๋์์์ ๊ด๋ฆฌ, ์ต์ ํ, ์ ์กํ ์ ์๋ ํ๋ซํผ์ ์ ๊ณตํ๋ ํด๋ผ์ฐ๋ ๊ธฐ๋ฐ ์๋น์ค : ์๋ฒ์ ์ด๋ฏธ์ง๋ฅผ ์ ์ฅํ์ง ์๊ณ storage์ ๋ฐ๋ก ์ด๋ฏธ์ง ํ์ผ์ ์ ์ฅํ๊ณ ์ ํจ npm i multer sharp cloudinary โ .env ํ์ผ์ ๋ฐ๋ก ์ ์ฅํ๊ธฐ // Configuration cloudinary.config({ cloud_name: "~~~", api_key: "~~", api_secret: "~~~" }); โ Multer : ํ์ผ์ ์ ๋ก๋ ํ๊ธฐ ์ํ node.js ๋ฏธ๋ค์จ์ด โ Sharp : nod..
=> Node.js E-Commerce App with REST API: Let's Build a Real-Life Example! ๐ท ์ฟ ํฐ ์กฐํํ๊ธฐ (GET) ๐ท ๋ชจ๋ ์ฟ ํฐ ์กฐํํ๊ธฐ (GET) ๐ท ์ฟ ํฐ ์์ฑํ๊ธฐ (POST) ๐ท ์ฟ ํฐ ์์ ํ๊ธฐ (PUT) ๐ท ์ฟ ํฐ ์ญ์ ํ๊ธฐ (DELETE) ๐ท ์ฝ๋ โ controllers/couponCtrl.js const Coupon = require("../models/Coupon"); const asyncHandler = require("express-async-handler"); const { validateMongodbID } = require("../utils/validateMongodbID"); // ๋ธ๋๋ ์์ฑํ๊ธฐ const createCoupon = asy..
=> Node.js E-Commerce App with REST API: Let's Build a Real-Life Example! ๐ท ์์๋ฆฌ์คํธ์ ์ํ ๋ฃ๊ธฐ ๐ท ์ํ ๋ณ์ ๋งค๊ธฐ๊ธฐ ํน์ field์ ๊ฐ์ ์์ ํ ๋ $set ์ฐ์ฐ์๋ฅผ ์ฌ์ฉ $elemMatch ๋ฐฐ์ด์์ ducument ์ฌ๋ฌ ํ๋๋ฅผ ์กฐ๊ฑด ๊ฑธ์ด์ ์ฐพ์ ๋ ์ฌ์ฉ โ Map : ๋ฐฐ์ด ๋ด์ ๋ชจ๋ ์์ ๊ฐ๊ฐ์ ๋ํ์ฌ ์ฃผ์ด์ง ํจ์๋ฅผ ํธ์ถํ ๊ฒฐ๊ณผ๋ฅผ ๋ชจ์ ์๋ก์ด ๋ฐฐ์ด์ ๋ฐํ ๋ฐฐ์ด.map((์์, ์ธ๋ฑ์ค, ๋ฐฐ์ด) => { return ์์ }); โ Reduce : ๋ฐฐ์ด์ ์ํํ๋ฉด์ ์ฝ๋ฐฑ ํจ์๋ฅผ ๋ฐ๋ณต ์คํํ๊ณ , ๋ชจ๋ ๋ฐ๋ณต์ ๊ฒฐ๊ณผ๋ฅผ ํ๋์ ๊ฐ์ผ๋ก ์ค์ด๋(reduce) ํจ์ ๋ฐฐ์ด.reduce((๋์ ๊ฐ, ํ์ฟ๊ฐ, ์ธ๋ฑ์ค, ์์) => { return ๊ฒฐ๊ณผ }, ์ด..
=> Node.js E-Commerce App with REST API: Let's Build a Real-Life Example! ๐ท ๋ธ๋๋ ์กฐํํ๊ธฐ (GET) ๐ท ๋ชจ๋ ๋ธ๋๋ ์กฐํํ๊ธฐ (GET) ๐ท ์ฝ๋ โ controllers/brandCtrl.js const Brand = require("../models/Brand"); const asyncHandler = require("express-async-handler"); const { validateMongodbID } = require("../utils/validateMongodbID"); // ๋ธ๋๋ ์์ฑํ๊ธฐ const createBrand = asyncHandler(async (req, res) => { try { const newBrand =..
=> Node.js E-Commerce App with REST API: Let's Build a Real-Life Example! ๐ท prodCategory & blogCategory ํ์ผ๋ช ๋ฐ๊พธ๊ธฐ ๐ท ์ฝ๋ โ controllers/prodCategoryCtrl.js const prodCategorySchema = require("../models/ProdCategory"); const asyncHandler = require("express-async-handler"); const { validateMongodbID } = require("../utils/validateMongodbID"); // ์นดํ ๊ณ ๋ฆฌ ์์ฑํ๊ธฐ const createCategory = asyncHandler(async (req, ..
=> Node.js E-Commerce App with REST API: Let's Build a Real-Life Example! ๐ท ์นดํ ๊ณ ๋ฆฌ ์กฐํํ๊ธฐ (GET) ๐ท ๋ชจ๋ ์นดํ ๊ณ ๋ฆฌ ์กฐํํ๊ธฐ (GET) ๐ท ์ฝ๋ โ controllers/prodCategoryCtrl.js const prodCategorySchema = require("../models/ProdCategory"); const asyncHandler = require("express-async-handler"); const { validateMongodbID } = require("../utils/validateMongodbID"); // ์นดํ ๊ณ ๋ฆฌ ์์ฑํ๊ธฐ const createCategory = asyncHandler(async (req,..