adrien2p 2 gadi atpakaļ
vecāks
revīzija
5666196fa2

+ 5 - 0
src/api/routes/admin/custom-route-handler.ts

@@ -0,0 +1,5 @@
+import { Request, Response } from 'express'
+
+export default async (req: Request, res: Response): Promise<void> => {
+  res.sendStatus(200)
+}

+ 17 - 0
src/api/routes/admin/index.ts

@@ -0,0 +1,17 @@
+import cors from "cors"
+import { Router } from "express"
+import bodyParser from "body-parser"
+import customRouteHandler from "./custom-route-handler"
+import { authenticate, wrapHandler } from "@medusajs/medusa";
+
+const adminRouter = Router()
+export function getStoreRouter(adminCorsOptions): Router {
+  adminRouter.use("/admin", cors(adminCorsOptions), authenticate(), bodyParser.json())
+
+  adminRouter.post(
+    "/my-custom-path",
+    wrapHandler(customRouteHandler)
+  )
+
+  return adminRouter
+}

+ 2 - 2
src/api/routes/store/index.ts

@@ -6,10 +6,10 @@ import { wrapHandler } from "@medusajs/medusa";
 
 const storeRouter = Router()
 export function getStoreRouter(storeCorsOptions): Router {
-  storeRouter.use(cors(storeCorsOptions), bodyParser.json())
+  storeRouter.use("/store", cors(storeCorsOptions), bodyParser.json())
 
   storeRouter.post(
-    "/store/my-custom-path",
+    "/my-custom-path",
     wrapHandler(customRouteHandler)
   )