Trx#8
Conversation
…l product, update totalprice pada tabel order
|
@zexoverz sir minta reviewnya sir |
zexoverz
left a comment
There was a problem hiding this comment.
Gokill sir, pengurangan quantity ini logic challange nya. lu udah notice aja udah keitung level up skill backend lu
|
|
||
| const getCategorys = catchAsync(async (req, res) => { | ||
| const result = await categoryService.queryCategorys(); | ||
| const {skip,take} = req.query |
There was a problem hiding this comment.
Nice pagination, pertahankan kek gini. logic pagination bakal sama aja kek gini terus. sampe lu kerja nanti konsep nya bakal kepake banget
| const adminAuth = () => async (req, res, next) => { | ||
|
|
||
| return new Promise((resolve, reject) => { | ||
| passport.authenticate('jwt', { session: false }, verifyCallback(req, resolve, reject))(req, res, next); | ||
| }) | ||
| .then(() => { | ||
| if(req.user.role==='admin'){ | ||
| next(); | ||
| }else{ | ||
| throw new ApiError(httpStatus.FORBIDDEN, 'You Are Not Admin'); | ||
| } | ||
| }) | ||
| .catch((err) => next(err)); | ||
| }; | ||
|
|
||
| module.exports = { | ||
| auth, | ||
| adminAuth, | ||
| }; No newline at end of file |
There was a problem hiding this comment.
Nice Authorization, udh tau kan berarti bedanya authenticate sama authorization.
fungsi nya Authorization ini limitasi akses role untuk fitur fitur backendnya
zexoverz
left a comment
There was a problem hiding this comment.
Overall udah OK Trx week4 nya. challange juga udah kelar semua. bisa di lanjutin ke week5 ke Testing dan deployment. kalo ada problem bisa chat gua aja di DC. gua udh mulai aktif lagi
|
@zexoverz sir minta review unit testingnya sir. |
| describe('User routes', ()=>{ | ||
| /* | ||
| describe('GET /v1/user', ()=>{ | ||
| beforeEach(async ()=>{ | ||
| await insertUsers([admin]); | ||
| await insertUsers([userOne]); | ||
| }) | ||
| test('should return 200 and successfully get all users if user role is admin', async ()=>{ | ||
| const res = await request(app) | ||
| .get('/v1/user') | ||
| .set('Authorization', `Bearer ${adminAccessToken}`) | ||
| .expect(httpStatus.OK); | ||
|
|
||
| }); | ||
| test('should return 401 unauthorized if token not set', async () => { | ||
| const res = await request(app) | ||
| .get('/v1/user') | ||
| .expect(httpStatus.UNAUTHORIZED); | ||
| }); | ||
|
|
||
| test('should return 403 forbidden if user role not admin', async ()=>{ | ||
| const res = await request(app) | ||
| .get('/v1/user') | ||
| .set('Authorization', `Bearer ${userOneAccessToken}`) | ||
| .expect(httpStatus.FORBIDDEN); | ||
|
|
||
| }); | ||
| }) | ||
| */ | ||
| describe('POST /v1/user', ()=>{ |
There was a problem hiding this comment.
coba di cocokin reponse dari user controller lu trx, soalnya response OBJ IS dari gua keknya beda sama punya lu.
ini uncomment trus cocokin sama response di user controller lu
|
Swaggernya kalo bisa di tambahin untuk API yang lain |
zexoverz
left a comment
There was a problem hiding this comment.
Nice EJS, tinggal testing nya aja trx di rapihin. kalo masih struggle kita bisa live class aja langsung di DC
zexoverz
left a comment
There was a problem hiding this comment.
Nice Swagger sir , semoga kepake ilmunya pas kerja di BE.
Swagger salah satu tools documentation paling umum di dunia kerja
|
Congrats Trx (peter), selamat atas kelulusannya di phase 1 🔥 🔥 🔥 Nilai lu disini kebantu banget sama perfom group project, itu final project lu gila banget wkwk. Reservation App termasuk top project di GP phase 1. overall nilai lu di phase 1 ada di angka 94%, penilaian ini base on: Review: untuk open gate phase 2 nanti di umumin jadwalnya, standby aja. bisa explore backend lagi kalau tertarik mau jadi backend developer : |
No description provided.