Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
kir4che committed Jan 21, 2024
1 parent 2e24ad5 commit c2454f7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 19 deletions.
10 changes: 2 additions & 8 deletions server/dist/controllers/order.controller.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/dist/controllers/order.controller.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/dist/controllers/post.controller.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/dist/controllers/post.controller.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions server/src/controllers/order.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ const getOrders = async (req: Request, res: Response) => {
try {
const userId = await auth(req)
const role: string = await UserModel.findById(userId).select('role')
if (role == 'admin') {
const orders = await OrderModel.find()
res.status(200).json({ message: 'Orders fetched successfully!', orders })
} else {
const orders = await OrderModel.find({ userId })
res.status(200).json({ message: 'Orders fetched successfully!', orders })
}

const orders = role == 'admin' ? await OrderModel.find() : await OrderModel.find({ userId })
res.status(200).json({ message: 'Orders fetched successfully!', orders })
} catch (err: any) {
res.status(500).json({ message: err.message })
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/post.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request, Response } from 'express'
import { PostModel } from '../models/post.model'

const getPost = async (res: Response) => {
const getPost = async (req: Request, res: Response) => {
try {
const posts = await PostModel.find()
res.status(200).json({ message: 'Posts fetched Successfully!', posts })
Expand Down

0 comments on commit c2454f7

Please sign in to comment.