Explorar o código

Fibo PoC: receive push data on a plain HTTP request over Connect.

Frederic G. MARAND %!s(int64=9) %!d(string=hai) anos
pai
achega
ff9cd7b35e

+ 1 - 0
.jshintrc

@@ -141,6 +141,7 @@
       "throwError": true,
       "validatePost": true,
 
+      "PushFeed": true,
 
       // - Fictive global just for the last comma
       "xyzzy": false

+ 2 - 0
.meteor/packages

@@ -12,3 +12,5 @@ sacha:spin
 ian:accounts-ui-bootstrap-3
 accounts-password
 audit-argument-checks
+fgm:errors
+webapp

+ 2 - 0
.meteor/versions

@@ -15,6 +15,7 @@ deps@1.0.7
 ejson@1.0.6
 email@1.0.6
 fastclick@1.0.3
+fgm:errors@0.0.1
 geojson-utils@1.0.3
 html-tools@1.0.4
 htmljs@1.0.4
@@ -41,6 +42,7 @@ minifiers@1.1.5
 minimongo@1.0.8
 mobile-status-bar@1.0.3
 mongo@1.1.0
+mongo-livedata@1.0.8
 npm-bcrypt@0.7.8_2
 observe-sequence@1.0.6
 ordered-dict@1.0.3

+ 1 - 0
client/templates/posts/posts_list.html

@@ -1,4 +1,5 @@
 <template name="postsList">
+  <div>{{lastPush}}</div>
   <div class="posts">
     {{#each posts}}
       {{> postItem}}

+ 4 - 0
client/templates/posts/posts_list.js

@@ -9,6 +9,10 @@
 Template.postsList.helpers({
   posts: function () {
     return Posts.find({}, { sort: { submitted: -1 }});
+  },
+  lastPush: function () {
+    var latest = PushFeed.find({}).count();//, { sort: { timestamp: -1}, limit: 1});
+    return latest;
   }
 });
 

+ 17 - 0
lib/collections/pushfeed.js

@@ -0,0 +1,17 @@
+/**
+ * @file
+ *
+ *
+ * User: marand
+ * Date: 04/09/15
+ * Time: 09:02
+ */
+PushFeed = new Mongo.Collection('push_feed');
+
+PushFeed.permissive = function () { return true; };
+
+PushFeed.allow({
+  'insert': PushFeed.permissive,
+  'update': PushFeed.permissive,
+  'remove': PushFeed.permissive,
+});

+ 4 - 1
lib/router.js

@@ -12,7 +12,10 @@ Router.configure({
   loadingTemplate: "loading",
   notFoundTemplate: "notFound",
   waitOn: function () {
-    return Meteor.subscribe('posts');
+    return [
+      Meteor.subscribe('posts'),
+      Meteor.subscribe('push_feed'),
+    ];
   }
 });
 

+ 19 - 0
server/ingestor.js

@@ -0,0 +1,19 @@
+/**
+ * @file
+ *
+ *
+ * User: marand
+ * Date: 04/09/15                                                              S
+ * Time: 08:57
+ */
+
+/**
+ * @param IncomingMessages req
+ * @param ServerResponse res
+ * @param function next
+ */
+WebApp.connectHandlers.use('/hello', function (req, res, next) {
+  res.writeHead(200);
+  res.end("Hello from Meteor " + Meteor.release);
+  PushFeed.insert({"timestamp": new Date()});
+});

+ 4 - 0
server/publications.js

@@ -11,6 +11,10 @@ Meteor.publish('posts', function() {
   return Posts.find();
 });
 
+Meteor.publish('push_feed', function() {
+  return PushFeed.find();
+});
+
 Meteor.publish('userData', function () {
   // If user is logged-in.
   if (this.userId) {