chore(medusa): cleanup test routes

This commit is contained in:
Sebastian Rindom
2020-08-27 09:53:22 +02:00
parent db205bf790
commit dd2980500e

View File

@@ -7,69 +7,6 @@ import errorHandler from "./middlewares/error-handler"
export default (container, config) => {
const app = Router()
app.post("/create-shipment/:order_id/:fulfillment_id", async (req, res) => {
const orderService = req.scope.resolve("orderService")
const eventBus = req.scope.resolve("eventBusService")
const order = await orderService.retrieve(req.params.order_id)
await orderService.createShipment(order._id, req.params.fulfillment_id, [
"1234",
])
res.sendStatus(200)
})
app.post("/run-hook/:order_id/refund", async (req, res) => {
const orderService = req.scope.resolve("orderService")
const eventBus = req.scope.resolve("eventBusService")
const order = await orderService.retrieve(req.params.order_id)
const returnToSend = order.refunds[order.refunds.length - 1]
eventBus.emit("order.refund_created", {
order,
refund: returnToSend,
})
res.sendStatus(200)
})
app.post("/run-hook/:order_id/return", async (req, res) => {
const orderService = req.scope.resolve("orderService")
const eventBus = req.scope.resolve("eventBusService")
const order = await orderService.retrieve(req.params.order_id)
const returnToSend = order.returns[0]
eventBus.emit("order.items_returned", {
order,
return: {
...returnToSend,
refund_amount: 1000,
},
})
res.sendStatus(200)
})
app.post("/run-hook/:order_id/capture", async (req, res) => {
const orderService = req.scope.resolve("orderService")
const eventBus = req.scope.resolve("eventBusService")
const order = await orderService.retrieve(req.params.order_id)
eventBus.emit("order.payment_captured", order)
res.sendStatus(200)
})
app.post("/run-hook/:order_id", async (req, res) => {
const orderService = req.scope.resolve("orderService")
const eventBus = req.scope.resolve("eventBusService")
const order = await orderService.retrieve(req.params.order_id)
eventBus.emit("order.placed", order)
res.sendStatus(200)
})
admin(app, container, config)
store(app, container, config)