Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var cote = require('cote'),
models = require('../models');
var purchaseResponder = new cote.Responder({
name: 'purchase responder',
namespace: 'purchase',
respondsTo: ['buy']
});
var purchasePublisher = new cote.Publisher({
name: 'purchase publisher',
namespace: 'purchase',
broadcasts: ['update']
});
var paymentRequester = new cote.Requester({
name: 'payment requester',
key: 'payment'
});
purchaseResponder.on('*', console.log);
purchaseResponder.on('buy', function(req, cb) {
var purchase = new models.Purchase({});
models.Product.get(req.productId, function(err, product) {
var cote = require('cote'),
models = require('../models');
var productResponder = new cote.Responder({
name: 'product responder',
namespace: 'product',
respondsTo: ['list']
});
var productPublisher = new cote.Publisher({
name: 'product publisher',
namespace: 'product',
broadcasts: ['update']
});
productResponder.on('*', console.log);
productResponder.on('list', function(req, cb) {
var query = req.query || {};
models.Product.find(query, cb);
});
productResponder.on('create', function(req, cb) {
models.Product.create(req.product, function(err, products) {
cb(err, products);
var cote = require('cote'),
models = require('../models');
var userResponder = new cote.Responder({
name: 'user responder',
namespace: 'user',
respondsTo: ['create']
});
var userPublisher = new cote.Publisher({
name: 'user publisher',
namespace: 'user',
broadcasts: ['update']
});
userResponder.on('*', console.log);
userResponder.on('create', function(req, cb) {
models.User.create({}, cb);
updateUsers();
});
userResponder.on('list', function(req, cb) {
var query = req.query || {};
models.User.find(query, cb);