Adds publish/subscribe pattern to allow plugins and projects to hook into events (#55)
Also adds CLI to ease development.
This commit is contained in:
1 parent
6a78df1ecd
commit
4c2aec2838
39 files changed
+6974
-444
No files matched your search
@@ -1,3 +1,4 @@
|
||||
/node_modules
|
||||
/dist
|
||||
.env
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
"author": "Sebastian Rindom",
|
||||
"license": "GPL-3.0",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.7.5",
|
||||
"@babel/core": "^7.7.5",
|
||||
"@babel/core": "^7.9.6",
|
||||
"@babel/node": "^7.7.4",
|
||||
"@babel/plugin-proposal-class-properties": "^7.7.4",
|
||||
"@babel/plugin-transform-instanceof": "^7.8.3",
|
||||
@@ -27,8 +26,12 @@
|
||||
"supertest": "^4.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/medusa": "^0.1.27",
|
||||
"bl": "^4.0.2",
|
||||
"express": "^4.17.1",
|
||||
"medusa-payment-stripe": "^0.1.27"
|
||||
"medusa-interfaces": "^0.1.27",
|
||||
"medusa-payment-stripe": "^0.1.27",
|
||||
"mongoose": "^5.9.12"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "nodemon --watch plugins/ --watch src/ --exec babel-node node_modules/@medusajs/medusa/dist/app.js"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class CartSubscriber {
|
||||
constructor({ cartService, eventBusService }) {
|
||||
this.eventBus_ = eventBusService
|
||||
|
||||
this.eventBus_.subscribe("cart.created", this.log)
|
||||
this.eventBus_.subscribe("cart.updated", this.log)
|
||||
}
|
||||
|
||||
async log(c) {
|
||||
console.log(c)
|
||||
}
|
||||
}
|
||||
|
||||
export default CartSubscriber
|
||||
+1033
-114
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user