Add redirect url

This commit is contained in:
Sebastian Rindom
2020-08-23 16:16:09 +02:00
parent 9699d6d1d0
commit c3898bcea4
5 changed files with 267 additions and 46 deletions
@@ -4,6 +4,20 @@ import bodyParser from "body-parser"
export default (container) => {
const app = Router()
app.post("/brightpearl/product", bodyParser.json(), async (req, res) => {
const { id, lifecycle_event } = req.body
if (lifecycle_event === "created") {
const eventBus = req.scope.resolve("eventBusService")
const brightpearlService = req.scope.resolve("brightpearlService")
const bpProduct = await brightpearlService.retrieveProduct(id)
eventBus.emit("brightpearl-product.created", bpProduct)
}
res.sendStatus(200)
})
app.post("/brightpearl/goods-out", bodyParser.json(), async (req, res) => {
const { id, lifecycle_event } = req.body
const brightpearlService = req.scope.resolve("brightpearlService")