Skip to content

Commit 21d0128

Browse files
authored
Merge pull request #81 from codeit-moving/dev
Dev -> release 20241227 14:26 리팩토링
2 parents d594bbe + 8aa827a commit 21d0128

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

src/controllers/quoteController.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,6 @@ import { isCustomer } from "../middlewares/authMiddleware";
88

99
const router = express.Router();
1010

11-
//견적서 상세 조회
12-
router.get(
13-
"/:id",
14-
passport.authenticate("jwt", { session: false }),
15-
isCustomer,
16-
asyncHandle(async (req, res, next) => {
17-
try {
18-
const { customerId } = req.user as { customerId: number };
19-
const { id: quoteId } = req.params;
20-
const quote = await quoteService.getQuoteById(
21-
customerId,
22-
parseInt(quoteId)
23-
);
24-
return res.status(200).send(quote);
25-
} catch (error) {
26-
next(error);
27-
}
28-
})
29-
);
30-
3111
// 견적서 생성하기
3212
router.post(
3313
"/",
@@ -186,4 +166,24 @@ router.get(
186166
})
187167
);
188168

169+
//견적서 상세 조회
170+
router.get(
171+
"/:id",
172+
passport.authenticate("jwt", { session: false }),
173+
isCustomer,
174+
asyncHandle(async (req, res, next) => {
175+
try {
176+
const { customerId } = req.user as { customerId: number };
177+
const { id: quoteId } = req.params;
178+
const quote = await quoteService.getQuoteById(
179+
customerId,
180+
parseInt(quoteId)
181+
);
182+
return res.status(200).send(quote);
183+
} catch (error) {
184+
next(error);
185+
}
186+
})
187+
);
188+
189189
export default router; // 설정한 라우터를 내보내서 다른 파일에서 사용할 수 있게 해요.

src/middlewares/authMiddleware.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export const isCustomer = async (
6767
moverId?: number;
6868
};
6969
const findUser = await userRepository.findById(user.id);
70-
7170
if (!findUser) {
7271
const error: CustomError = new Error("Unauthorized");
7372
error.status = 403;
@@ -110,7 +109,6 @@ export const isMover = async (
110109
};
111110
return next(error);
112111
}
113-
114112
if (!user?.moverId) {
115113
const error: CustomError = new Error("Unauthorized");
116114
error.status = 403;

0 commit comments

Comments
 (0)