Guest User

Untitled

a guest
Jan 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1.  
  2. // SETUP
  3.  
  4. // Get the required modules
  5. var express = require("express"),
  6. mustachio = require("mustachio"),
  7. sys = require("sys"),
  8. app = express.createServer();
  9.  
  10. // Configure the app
  11. app.configure(function() {
  12. app.use(express.static(__dirname + '/public'));
  13. app.register('.mustache', mustachio);
  14. app.set('view engine', 'mustache');
  15. });
  16.  
  17. // CONFIG FOR TWITTER
  18. var config = {
  19. user: "",
  20. password: "",
  21. track: ["#nodetwitter"]};
  22.  
  23. var socket = require('socket.io').listen(app),
  24. twitter = new (require("twitter-node").TwitterNode)(config);
  25.  
  26. socket.addListener('clientMessage', function(data, client){
  27. client.sockets.send(data);
  28. });
  29.  
  30. twitter
  31. .addListener('error', function(error){ // Always check for errors or they popup client side
  32. console.log(error.message);
  33. })
  34. .addListener('tweet', function(tweet){ // A new tweet that matches the criteria has been located
  35. socket.emit('clientMessage', tweet, socket);
  36. })
  37. .addListener('limit', function(limit){ // New limit has been sent from the API
  38. sys.puts('LIMIT: ' + sys.inspect(limit));
  39. })
  40. .addListener('delete', function(del){ // A delete event occured
  41. sys.puts('DELETE: ' + sys.inspect(del));
  42. })
  43. .addListener('end', function(resp){ // API disconnect
  44. sys.puts('wave goodbye...' + resp.statusCode);
  45. })
  46. .stream();
  47.  
  48. // END SETUP
  49.  
  50. // CONTROLLERS
  51. app.get("/", function(req, res){
  52.  
  53. // Render the layout
  54. res.render('layout', {
  55. title: "Amy and Steve Wedding"
  56. });
  57. });
  58. // END CONTROLLERS
  59.  
  60. // GO GO GO!
  61. app.listen(3000);
  62. console.log("HTTP Server Started");
Add Comment
Please, Sign In to add comment