-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.js
35 lines (32 loc) · 1.57 KB
/
entrypoint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import addressRouter from './components/address/address_router';
import authRouter from './components/auth/auth_routes';
import brandRouter from './components/brand/brand_routes';
import cartRouter from './components/cart/cart_routes';
import categoryRouter from './components/category/category_routes';
import couponRouter from './components/coupon/coupon_routes';
import orderRouter from './components/order/order_routes';
import productRouter from './components/products/product_routes';
import reviewRouter from './components/review/review_routes';
import subCategoryRouter from './components/subcategory/subcategory_routes';
import userRouter from './components/user/user_routes';
import wishListRouter from './components/wishlist/wishlist_routes';
import { AppError } from './utils/app_error';
import { globalErrorHandling } from './middleware/global_error_handler';
export function entrypoint(app) {
app.use("/api/v1/categories", categoryRouter);
app.use("/api/v1/subcategories", subCategoryRouter);
app.use("/api/v1/brands", brandRouter);
app.use("/api/v1/products", productRouter);
app.use("/api/v1/users", userRouter);
app.use("/api/v1/auth", authRouter);
app.use("/api/v1/review", reviewRouter);
app.use("/api/v1/wishlist", wishListRouter);
app.use("/api/v1/address", addressRouter);
app.use("/api/v1/coupons", couponRouter);
app.use("/api/v1/carts", cartRouter);
app.use("/api/v1/orders", orderRouter);
app.all("*", (req, res, next) => {
next(new AppError("Endpoint was not found", 404));
});
app.use(globalErrorHandling);
}