Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ecommerce-microservices-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Povilas Lajus 20194551
ecommerce-microservices-web
Commits
ea42339d
Commit
ea42339d
authored
Mar 10, 2023
by
Povilas Lajus
Browse files
Options
Downloads
Patches
Plain Diff
feat: add order update
parent
67a3d859
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
carts/src/services/validator.ts
+1
-0
1 addition, 0 deletions
carts/src/services/validator.ts
orders/src/routes/orders.router.ts
+4
-2
4 additions, 2 deletions
orders/src/routes/orders.router.ts
orders/src/services/orderValidator.ts
+24
-7
24 additions, 7 deletions
orders/src/services/orderValidator.ts
with
29 additions
and
9 deletions
carts/src/services/validator.ts
+
1
−
0
View file @
ea42339d
...
...
@@ -11,6 +11,7 @@ const validate = (req: Request, res: Response, next: NextFunction) => {
export
const
validateProductOperation
=
[
param
(
"
id
"
).
exists
().
trim
(),
body
(
"
productId
"
).
exists
(),
body
(
"
amount
"
).
optional
().
isNumeric
(),
validate
,
];
...
...
This diff is collapsed.
Click to expand it.
orders/src/routes/orders.router.ts
+
4
−
2
View file @
ea42339d
...
...
@@ -4,7 +4,7 @@ import OrdersController from "../controllers/orders.controller";
import
{
validateFindById
,
validateNewOrder
,
validateUpdateOrder
Status
,
validateUpdateOrder
,
}
from
"
../services/orderValidator
"
;
export
const
router
=
express
.
Router
();
...
...
@@ -19,4 +19,6 @@ router.get("/:id", validateFindById, orders.getOrder);
router
.
post
(
"
/
"
,
validateNewOrder
,
orders
.
createOrder
);
router
.
put
(
"
/status/update
"
,
validateUpdateOrderStatus
,
orders
.
updateStatus
);
router
.
put
(
"
/:id
"
,
validateUpdateOrder
,
orders
.
updateOrder
);
router
.
delete
(
"
/:id
"
,
validateFindById
,
orders
.
deleteOrder
);
This diff is collapsed.
Click to expand it.
orders/src/services/orderValidator.ts
+
24
−
7
View file @
ea42339d
...
...
@@ -13,10 +13,10 @@ export const validateNewOrder = [
body
(
"
status
"
)
.
optional
()
.
isIn
([
"
New
"
,
"
Pending
"
,
"
Hold
"
,
"
Shipped
"
,
"
Delivered
"
]),
body
(
"
total
"
).
exists
().
is
Numeric
(),
body
(
"
total
"
).
exists
().
is
String
(),
body
(
"
addressId
"
).
exists
().
not
().
isEmpty
(),
body
(
"
paymentId
"
).
exists
().
not
().
isEmpty
(),
body
(
"
addressId
"
).
exists
().
not
().
isEmpty
()
.
isNumeric
()
,
body
(
"
paymentId
"
).
exists
().
not
().
isEmpty
()
.
isNumeric
()
,
body
(
"
orderItems
"
).
exists
().
isArray
(),
body
(
"
orderItems.*.productId
"
).
exists
().
isString
(),
...
...
@@ -24,11 +24,28 @@ export const validateNewOrder = [
validate
,
];
export
const
validateUpdateOrderStatus
=
[
// export const validateUpdateOrderStatus = [
// param("id").exists(),
// body("newStatus")
// .exists()
// .isIn(["New", "Pending", "Hold", "Shipped", "Delivered"]),
// validate,
// ];
export
const
validateUpdateOrder
=
[
param
(
"
id
"
).
exists
(),
body
(
"
newStatus
"
)
oneOf
([
body
(
"
status
"
)
.
exists
()
.
isIn
([
"
New
"
,
"
Pending
"
,
"
Hold
"
,
"
Shipped
"
,
"
Delivered
"
]),
body
(
"
addressId
"
).
exists
().
not
().
isEmpty
().
isNumeric
(),
body
(
"
paymentId
"
).
exists
().
not
().
isEmpty
().
isNumeric
(),
]),
body
(
"
customerEmail
"
).
not
().
exists
(),
body
(
"
total
"
).
not
().
exists
(),
body
(
"
orderItems
"
).
not
().
exists
(),
validate
,
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment