Guest User

Untitled

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