-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
index.js
83 lines (71 loc) · 2.29 KB
/
index.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { Router } from "express"
import cors from "cors"
import middlewares from "../../middlewares"
import authRoutes from "./auth"
import productRoutes from "./products"
import userRoutes, { unauthenticatedUserRoutes } from "./users"
import inviteRoutes, { unauthenticatedInviteRoutes } from "./invites"
import regionRoutes from "./regions"
import shippingOptionRoutes from "./shipping-options"
import shippingProfileRoutes from "./shipping-profiles"
import discountRoutes from "./discounts"
import giftCardRoutes from "./gift-cards"
import orderRoutes from "./orders"
import returnReasonRoutes from "./return-reasons"
import storeRoutes from "./store"
import uploadRoutes from "./uploads"
import customerRoutes from "./customers"
import appRoutes from "./apps"
import swapRoutes from "./swaps"
import returnRoutes from "./returns"
import variantRoutes from "./variants"
import draftOrderRoutes from "./draft-orders"
import collectionRoutes from "./collections"
import notificationRoutes from "./notifications"
import noteRoutes from "./notes"
const route = Router()
export default (app, container, config) => {
app.use("/admin", route)
const adminCors = config.admin_cors || ""
route.use(
cors({
origin: adminCors.split(","),
credentials: true,
})
)
// Unauthenticated routes
authRoutes(route)
// reset password
unauthenticatedUserRoutes(route)
// accept invite
unauthenticatedInviteRoutes(route)
const middlewareService = container.resolve("middlewareService")
// Calls all middleware that has been registered to run before authentication.
middlewareService.usePreAuthentication(app)
// Authenticated routes
route.use(middlewares.authenticate())
// Calls all middleware that has been registered to run after authentication.
middlewareService.usePostAuthentication(app)
appRoutes(route)
productRoutes(route)
userRoutes(route)
regionRoutes(route)
shippingOptionRoutes(route)
shippingProfileRoutes(route)
discountRoutes(route)
giftCardRoutes(route)
orderRoutes(route)
storeRoutes(route)
uploadRoutes(route)
customerRoutes(route)
swapRoutes(route)
returnRoutes(route)
variantRoutes(route)
draftOrderRoutes(route)
collectionRoutes(route)
notificationRoutes(route)
returnReasonRoutes(route)
noteRoutes(route)
inviteRoutes(route)
return app
}