Clients can also answer each other questions, so let's build that feature by first listening for the'answer' event on the client, which will send us both the question and answer, which we want to broadcast out to the rest of the connected clients. va…
Below we've already created an express server, but we want to start building a real-time Q&A moderation service and we've decided to use socket.io. Require socket.io and make sure it listens for requests on the express app. Also, print out a message…
Let's go back to our live-moderation app and add some persistence, first to the questions people ask. Use the lpush command to add new questions to the list named questions. Do this inside thequestion listener. var express = require('express'); var a…
今天在WebStorm下熟悉一个node.js的项目,配置环境时,手一抖,将mysql包从0.8升级到了2.1.1,结果再运行时就出错了. [Fri Mar 14 2014 17:05:49] 连接数据库失败:TypeError: Object #<Object> has no method 'createClient' TypeError: Object false has no method 'query'    at getPlayedFun (C:\Users\Administrato…
Let's start practicing using the redis key-value store from our node application. First require the redismodule, and then create a redis client that we can use to call commands on our redis server. Use the client to set the name key to your name. var…
Create an express route that responds to GET requests at the URL /tweets that responds with the filetweets.html located in the same directory as app.js Make sure you create the app and listen on port 8080 var express = require('express'); var app = e…
Now let's create an express server which queries out for this search term and just returns the json. You'll need to do a few things: Require the express module Create the express server 'app' On a get request to '/', pipe the request(searchURL) to th…
Instead of just writing out the quote to the response, instead render the quote.ejs template, passing in the quote name and quote body. Then finish the quote.ejs view, by printing out the quote name and body. var express = require('express'); var app…
Create a route that responds to a GET request '/quotes/<name>', then use the param from the URL to retrieve a quote from the quotes object and write it out to the response. Note: No piping here, just write the quote string to the response like you d…
Update the versions on your dependencies to be a little more flexible, adding the ~ in front of your versions. package.json { "name": "My Awesome Node App", "version": "1", "dependencies": { "connect&…