Skip to content

Conversation

@aldoLorenzio
Copy link

No description provided.

Comment on lines 5 to 35
const createOrderItem = async (orderItemBody) => {
const order = await prisma.product.findUnique({
where:{
id: orderItemBody.orderId
}
})

const product = await prisma.product.findUnique({
where:{
id: orderItemBody.productId
}
})


if(!order) throw new ApiError(httpStatus.NOT_FOUND, 'Order ID not found')
if(!product) throw new ApiError(httpStatus.NOT_FOUND, 'Product ID not found')
if(orderItemBody.quantity > product.quantityInStock) throw new ApiError (httpStatus.BAD_REQUEST, `Order quantity exceed product stock. Current product stock is ${product.quantityInStock}`)

await prisma.product.update({
where:{
id: product.id
},
data: product.quantityInStock - orderItemBody.quantity
})


return prisma.orderItem.create({
data: orderItemBody
});
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice OrderItem Logic, Handle quantity stock ini MVP challange nya di IS. mantep progressnya do

Comment on lines 21 to 42
const getUsers = async (filters, options) => {
const {name,role,email} = filters
const {take, skip} = options

return prisma.user.findMany({
where:{
name:{
contains: name,
},
role:{
contains: role
},
email:{
contains:email
}},
take: take && parseInt(take),
skip: skip && parseInt(skip),
orderBy:{
name: 'asc'
}
});
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice Pagination, diinget terus ya do konsep pagination. ini konsep kepake banget pas kerja jadi BE

Comment on lines 22 to 40
const authAdmin = () => async (req,res,next) => {
return new Promise((resolve, reject) =>{
passport.authenticate('jwt', {session: false}, verifyCallback(req, resolve, reject))(req,res,next);
})
.then(() => {
const user = req.user
if(user.role === 'admin'){
next()
}else{
throw new ApiError(httpStatus.FORBIDDEN, "This role doesn't has access")
}
})
.catch((err) => next(err))
}

module.exports = {
auth,
authAdmin
}
Copy link
Contributor

Choose a reason for hiding this comment

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

mantepp authorization, kalau udah bisa bedain authenticate sama authorization. Skill BE lu udah Oke banget. ini konsep juga penting banget di kerjaan

Copy link
Contributor

@zexoverz zexoverz left a comment

Choose a reason for hiding this comment

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

Week4 Approve ya do, congratss challangenya kelar semua. lanjut week5 ya di testing sama deployment. kalo ada problem bisa langsung tanya gua aja di channel. gua udh mulai aktif lagi

@zexoverz
Copy link
Contributor

zexoverz commented Feb 7, 2024

reviewed, lanjutin do testing nya. gaskann

@zexoverz
Copy link
Contributor

zexoverz commented Apr 29, 2024

Congrats Dodo, selamat atas kelulusannya di phase 1 🔥 🔥 🔥
lu termasuk anak yang konsisten di progress, walaupun ga cepet cepet tapi selalu upgrade tiap hari.

overall nilai lu di phase 1 ada di angka 86%, penilaian ini base on:
-Logic Handling
-Explore
-Question Ask
-Learn Speed
-Task Submit

Review:
untuk phase 1 progress lu udah bagus do. walaupun ga secepet anak batch 1, lu tetep ada progress di setiap harinya. kalaupun gua juga lagi sibuk, lu tetep nyetor commit di PR. gua salut lu bisa konsisten sampe akhir.
paling saran dari gua, lu kan waktu kosong banyak nih do. bisa coba belajar pake resource lain, jangan di RPN aja. biar lu dapet insight dari luar dan lu bisa validasi ilmunya sendiri. mumpung lu lagi haus akan grinding, coba explore lebih dalem lagi tentang backend dan banyakin jam terbang. sering sering buat project pake template gua, tackle problem problem susah macem e commerce atau ticketing online. untuk logic handling lu udah bagus do, jadi tinggal banyakin praktek aja biar jam terbang lu gede.

untuk open gate phase 2 nanti di umumin jadwalnya, standby aja.

Untuk mengisi liburan , bisa explore backend lagi kalau tertarik mau jadi backend developer :

  • Explore Payment Gateway (Stripe)
  • Explore Cache (redis)
  • Explore Microservice Architecture

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