-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SLein #10
Open
yogiwijaya777
wants to merge
130
commits into
RPN-Phase-1:main
Choose a base branch
from
yogiwijaya777:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
SLein #10
Changes from 1 commit
Commits
Show all changes
130 commits
Select commit
Hold shift + click to select a range
7061c88
Added MongoDB Completion
yogiwijaya777 0da3852
Merge pull request #1 from yogiwijaya777/yogi
yogiwijaya777 713bb7d
Adding Folder/File Structure
yogiwijaya777 3490ceb
Complete Todo & User model
yogiwijaya777 4d700d8
USer Router completed
yogiwijaya777 a7d7c0c
Todos Router Complete
yogiwijaya777 a4368ee
Completing Router Index
yogiwijaya777 7c2f26f
Refactoring Todo Schema
yogiwijaya777 cb54aa2
Setting up editorconfig
yogiwijaya777 143ea07
Refactor All Files Following ESLint rules
yogiwijaya777 ddda428
Adding createTask feature
yogiwijaya777 c4b430f
Adding Get All Users API
yogiwijaya777 7c25b21
Adding Get User API
yogiwijaya777 c76880f
Adding Delete User API
yogiwijaya777 007f3b7
Adding Update User API
yogiwijaya777 e41dc7f
Adding TODOS API
yogiwijaya777 054ae66
Merge pull request #2 from yogiwijaya777/yogi
yogiwijaya777 e77f2ff
Starting Project fancy-todo-orm
yogiwijaya777 c94a3a2
Merge pull request #3 from yogiwijaya777/yogi
yogiwijaya777 b8171b8
Setting up Prisma
yogiwijaya777 8acfd92
Merge pull request #4 from yogiwijaya777/yogi
yogiwijaya777 7c74450
Setting up app.js and index.js
yogiwijaya777 e73a1cd
Adding services file
yogiwijaya777 75f5571
Setting up todo.service.js
yogiwijaya777 de3452a
Setting up user.service.js
yogiwijaya777 f94aa78
Adding controllers file
yogiwijaya777 0e58e3c
Setting up user controller
yogiwijaya777 a369921
Setting up todo controller
yogiwijaya777 c744ac5
Setting up routers
yogiwijaya777 11c3621
Push todo-fancy-orm
yogiwijaya777 d2d84b7
Merge pull request #5 from yogiwijaya777/yogi
yogiwijaya777 fc9c6bb
Adding Code Standarization
yogiwijaya777 9f9cd74
npx prisma init
yogiwijaya777 919fa01
Adding Schema onf DB
yogiwijaya777 dade522
Adding prisma client.js
yogiwijaya777 001f0b6
Setting up basic server app.js
yogiwijaya777 3bb6939
Setting up index.js
yogiwijaya777 7563365
Merge pull request #6 from yogiwijaya777/yogi
yogiwijaya777 ad34bad
Adding config.js
yogiwijaya777 45e7d58
setting up loggin system winston
yogiwijaya777 64cc51e
Setting Up Morgan logging
yogiwijaya777 4077c25
Merge pull request #7 from yogiwijaya777/yogi
yogiwijaya777 d486ffb
Setting up ApiError
yogiwijaya777 1a5d48f
setting up cactchAsync
yogiwijaya777 2befc4e
setting ap middleware rror.js
yogiwijaya777 824dd94
Merge pull request #8 from yogiwijaya777/yogi
yogiwijaya777 26ec787
setting up backend security
yogiwijaya777 fc90cd9
Merge pull request #9 from yogiwijaya777/yogi
yogiwijaya777 347855b
Setting ap Auth
yogiwijaya777 d31b9a2
Merge pull request #10 from yogiwijaya777/yogi
yogiwijaya777 98a7778
Backend Validation
yogiwijaya777 437f32f
Merge pull request #11 from yogiwijaya777/yogi
yogiwijaya777 6fb6906
testing authentication tokes via cookies
yogiwijaya777 17716ff
queryCategorys
yogiwijaya777 92dbfed
Merge pull request #12 from yogiwijaya777/yogi
yogiwijaya777 933f1b6
fix error
yogiwijaya777 57783f2
Merge pull request #13 from yogiwijaya777/yogi
yogiwijaya777 3899510
createProduct complete
yogiwijaya777 f76da86
queryProducts + logic complete
yogiwijaya777 6b9a42b
setting auth middleware set req.user without password
yogiwijaya777 493ef80
Merge pull request #14 from yogiwijaya777/yogi
yogiwijaya777 d49954a
getProductById complete
yogiwijaya777 b107ce8
getuser complete
yogiwijaya777 81ed9a3
getproductbyuser complete
yogiwijaya777 8660d29
refactor getProductByUser
yogiwijaya777 9dfec45
refactor querys logic
yogiwijaya777 69b3a86
refactor category and product query logic only show need information
yogiwijaya777 202ef73
refresh token logic complete
yogiwijaya777 fd26490
refactor refresh tokens
yogiwijaya777 025313b
logout API complete
yogiwijaya777 11b3ce0
Merge pull request #15 from yogiwijaya777/yogi
yogiwijaya777 4f59d52
createUser API
yogiwijaya777 dfdd825
getUserById Complete
yogiwijaya777 66b98d9
updateUser Complete
yogiwijaya777 3c9c196
deleteUser complete
yogiwijaya777 e75686e
setup order.validation.js
yogiwijaya777 4329439
setup orderItem.validation.js
yogiwijaya777 e92f711
Merge pull request #16 from yogiwijaya777/yogi
yogiwijaya777 e30afdb
createOrder and getAllOrders complete
yogiwijaya777 dc22167
createOrder and getAllOrders complete
yogiwijaya777 1707c9d
getOrder complete
yogiwijaya777 51e26ed
updateUser complete
yogiwijaya777 62e9d54
deleteOrder complete
yogiwijaya777 fcbaef4
Merge pull request #17 from yogiwijaya777/yogi
yogiwijaya777 31f12dd
createOrderItem logic complete
yogiwijaya777 70e4ef2
getOrder compelte
yogiwijaya777 c1818f3
update service logic complete
yogiwijaya777 2c46690
deleteOrderITem logic complete
yogiwijaya777 506c470
get order item by order complete
yogiwijaya777 b48d12a
get orders by user complete
yogiwijaya777 f4c6920
Merge pull request #18 from yogiwijaya777/yogi
yogiwijaya777 2d08e4c
refactor register controller & service toBe expected for testing
yogiwijaya777 ae43ce5
[__mocks/index.js]Adding beforeEach for deleteMany category
yogiwijaya777 bf127ac
category.test POST & GET
yogiwijaya777 a1d8b10
PATCH testing for categories id route
yogiwijaya777 45e5215
fix error PATCH and adding DELETE testing
yogiwijaya777 0633fbb
Merge pull request #19 from yogiwijaya777/yogi
yogiwijaya777 fd01272
addproducts testing 30%
yogiwijaya777 c0628d1
refactor to newesr faker-js
yogiwijaya777 b3151b4
Merge pull request #20 from yogiwijaya777/yogi
yogiwijaya777 1d459a0
refactor product.test and adding more test on POST method
yogiwijaya777 326ae4e
product testing complete
yogiwijaya777 208ac84
Merge pull request #21 from yogiwijaya777/yogi
yogiwijaya777 22f9ae1
queryLogic change
yogiwijaya777 f78b5ee
refactor user service
yogiwijaya777 5b0eaa1
user.test POST
yogiwijaya777 537bd6e
Merge pull request #22 from yogiwijaya777/yogi
yogiwijaya777 9b54ba8
GET user.testing complete
yogiwijaya777 d8848ba
GET:id Users and fix error GET
yogiwijaya777 eab8a26
PATCH user.test complete
yogiwijaya777 6b3cf43
REFACTOR PATCH user.testing
yogiwijaya777 741e774
DELETE user testing completed
yogiwijaya777 b3622c8
Merge pull request #23 from yogiwijaya777/yogi
yogiwijaya777 06296f4
order fixture and post first test
yogiwijaya777 4765bb7
Merge pull request #24 from yogiwijaya777/yogi
yogiwijaya777 b954711
order test complete
yogiwijaya777 41c425e
Merge pull request #25 from yogiwijaya777/yogi
yogiwijaya777 d07a2ee
orderItems logic and first test orderItems
yogiwijaya777 7278980
orderItem.test POST complete
yogiwijaya777 769374b
GET ordeItem.testing complete
yogiwijaya777 8b2379e
GET:ID, PATCH:ID, and adding more testing on POST
yogiwijaya777 9a9906c
order.testing : PATCH refactor, DELETE ctesting Complete
yogiwijaya777 35d28ef
refactor user authorization to admin, refactor error auth.test , all …
yogiwijaya777 565a077
Create README.md
yogiwijaya777 66081ae
Update README.md
yogiwijaya777 90eb1f9
documentation and serving bit ejs and css
yogiwijaya777 8bf3ab6
editing readme.md
yogiwijaya777 be49acf
Update README.md
yogiwijaya777 531ed37
Merge pull request #27 from yogiwijaya777/yogi
yogiwijaya777 d178e66
Update README.md
yogiwijaya777 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const httpStatus = require('http-status'); | ||
const catchAsync = require('../utils/catchAsync'); | ||
const { orderService } = require('../services'); | ||
|
||
const createOrder = catchAsync(async (req, res) => { | ||
const order = await orderService.createOrder(req.body); | ||
|
||
res.status(httpStatus.CREATED).send({ | ||
status: httpStatus.CREATED, | ||
message: 'Create Order Success', | ||
data: order, | ||
}); | ||
}); | ||
|
||
const getAllOrders = catchAsync(async (req, res) => { | ||
const filter = { total: req.query.total }; | ||
const options = { | ||
take: req.query.take || 10, | ||
page: req.query.page || 1, | ||
sort: req.query.sort === 'latest' ? { date: 'desc' } : { date: 'asc' }, | ||
}; | ||
|
||
const orders = await orderService.queryOrders(filter, options); | ||
|
||
res.status(httpStatus.OK).send({ | ||
status: httpStatus.OK, | ||
message: 'Get Orders Success', | ||
data: orders, | ||
}); | ||
}); | ||
|
||
module.exports = { | ||
createOrder, | ||
getAllOrders, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const httpStatus = require('http-status'); | ||
const catchAsync = require('../utils/catchAsync'); | ||
const { orderService } = require('../services'); | ||
|
||
const createOrderItem = catchAsync(async (req, res) => { | ||
const orderItem = await orderService.createOrderItem(req.body); | ||
|
||
res.status(httpStatus.CREATED).send({ | ||
status: httpStatus.CREATED, | ||
message: 'Create OrderItem Success', | ||
data: orderItem, | ||
}); | ||
}); | ||
|
||
module.exports = { | ||
createOrderItem, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const express = require('express'); | ||
const { auth, authorizePermissions } = require('../../middlewares/auth'); | ||
const validate = require('../../middlewares/validate'); | ||
const { orderValidation } = require('../../validations'); | ||
const orderController = require('../../controllers/order.controller'); | ||
|
||
const router = express.Router(); | ||
|
||
router | ||
.route('/') | ||
.get(auth(), authorizePermissions('admin'), orderController.getAllOrders) | ||
.post(auth(), authorizePermissions('admin'), validate(orderValidation.createOrder), orderController.createOrder); | ||
|
||
module.exports = router; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const httpStatus = require('http-status'); | ||
const prisma = require('../../prisma/client'); | ||
const ApiError = require('../utils/ApiError'); | ||
|
||
const createOrder = async (body) => { | ||
const order = await prisma.order.create({ data: body }); | ||
return order; | ||
}; | ||
|
||
const queryOrders = async (filter, options) => { | ||
const { total: totalPrice } = filter; | ||
const { take, skip, sort: orderBy } = options; | ||
|
||
const orders = await prisma.order.findMany({ | ||
where: { | ||
totalPrice: { | ||
lte: totalPrice, | ||
}, | ||
}, | ||
orderBy, | ||
take: Number(take), | ||
skip, | ||
}); | ||
|
||
if (!orders) throw new ApiError(httpStatus.NOT_FOUND, 'Orders not found'); | ||
|
||
return orders; | ||
}; | ||
|
||
module.exports = { | ||
createOrder, | ||
queryOrders, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const prisma = require('../../prisma/client'); | ||
const httpStatus = require('http-status'); | ||
const ApiError = require('../utils/ApiError'); | ||
|
||
const createOrderItem = async (data) => { | ||
const orderItem = await prisma.orderItem.create({ | ||
data, | ||
}); | ||
return orderItem; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice options filter, additional sorting gini lumayan kepake buat front end nyari data historical