Skip to content

Commit fc247f6

Browse files
committed
feat: 각 함수명 수정 및 route 경로 설정
1 parent 2c2fdcc commit fc247f6

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

packages/vanilla/server.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ async function createServer() {
2828
app.use(base, sirv("./dist/vanilla", { extensions: [] }));
2929
}
3030

31-
// issue: express 5.x 에서는 * 대신 {*splat} 사용
32-
// 관련 링크: https://expressjs.com/ko/guide/migrating-5.html#path-syntax
33-
app.use("/{*splat}", async (req, res) => {
31+
app.use(async (req, res) => {
3432
try {
3533
const url = req.originalUrl.replace(base, "");
3634

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function filterProducts(products, query) {
8181
* @param {Object} params - 조회 파라미터
8282
* @returns {Object} 상품 목록과 페이지네이션 정보
8383
*/
84-
export async function mockGetProducts(params = {}) {
84+
export async function getProducts(params = {}) {
8585
const { limit = 20, search = "", category1 = "", category2 = "", sort = "price_asc" } = params;
8686
const page = params.current ?? params.page ?? 1;
8787

@@ -125,7 +125,7 @@ export async function mockGetProducts(params = {}) {
125125
* @param {string} productId - 상품 ID
126126
* @returns {Object|null} 상품 상세 정보
127127
*/
128-
export async function mockGetProduct(productId) {
128+
export async function getProduct(productId) {
129129
const products = loadItems();
130130
const product = products.find((item) => item.productId === productId);
131131

@@ -148,6 +148,6 @@ export async function mockGetProduct(productId) {
148148
* 서버에서 사용할 카테고리 목록 조회 함수
149149
* @returns {Object} 카테고리 목록
150150
*/
151-
export async function mockGetCategories() {
151+
export async function getCategories() {
152152
return getUniqueCategories();
153153
}

packages/vanilla/src/main-server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { mockGetProducts, mockGetCategories, mockGetProduct } from "./api/mockApi.js";
1+
import { getProducts, getCategories, getProduct } from "./api/routes.js";
22
import { ServerRouter } from "./router/serverRouter.js";
33

44
const serverRouter = new ServerRouter();
55

66
serverRouter.addRoute("/", async (params, query) => {
77
const [productsData, categories] = await Promise.all([
8-
mockGetProducts({ ...query, limit: query.limit || 20 }),
9-
mockGetCategories(),
8+
getProducts({ ...query, limit: query.limit || 20 }),
9+
getCategories(),
1010
]);
1111

1212
return {
@@ -21,7 +21,7 @@ serverRouter.addRoute("/", async (params, query) => {
2121
});
2222

2323
serverRouter.addRoute("/product/:id/", async (params) => {
24-
const product = await mockGetProduct(params.id);
24+
const product = await getProduct(params.id);
2525

2626
if (!product) {
2727
return {

0 commit comments

Comments
 (0)