“通知服务并不是必须包含令人兴奋的消息才是有用的通知服务。”
1 2 3 4 5 6 | console.log ('registering event routes with express'); app.get('/events', event.findAll); app.get('/events/:id', event.findById); app.post('/events', event.addEvent); app.put('/events/:id', event.updateEvent); app.delete('/events/:id', event.deleteEvent); |
1 2 3 4 5 6 | console.log ('registering subscription routes with express'); app.get('/subscriptions', sub.findAll); app.get('/subscriptions/:id', sub.findById); app.post('/subscriptions', sub.addSubscription); app.put('/subscriptions/:id', sub.updateSubscription); app.delete('/subscriptions/:id', sub.deleteSubscription); |
1 | app.post('/signals', signal.processSignal); |
1 | app.get('/signallog', signallog.findRecent); |
1 2 3 4 5 6 7 8 9 10 | exports.findAll = function(req, res) { mongo.Db.connect(mongoUri, function (err, db) { db.collection('events', function(er, collection) { collection.find().toArray(function(err, items) { res.send(items); db.close(); }); }); }); } |
1 2 3 4 5 6 7 8 9 10 11 12 | exports.deleteEvent = function(req, res) { var id = req.params.id; mongo.Db.connect(mongoUri, function (err, db) { db.collection('events', function(err, collection) { collection.remove({'_id':new BSON.ObjectID(id)}, {safe:true}, function(err, result) { res.send(req.body); db.close(); }); }); }); } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |