随笔分类 - Node.js
摘要:Express RoutesLet's create an express route that acceptsGETrequests on'/tweets'and responds by sending back a static HTML file.Create aGETroute for'/t...
阅读全文
posted @ 2014-11-12 04:01
Zhentiw
摘要:4.2Missing ExportsNotice the two different files:high_five.json the left side andapp.json the right. The code as it's written will not work,high_five....
阅读全文
posted @ 2014-11-08 02:40
Zhentiw
摘要:File Read StreamLets use thefsmodule to read a file and log its contents to the console.Use thefsmodule to create aReadablestream forfruits.txt. Store...
阅读全文
posted @ 2014-11-02 23:17
Zhentiw
摘要:Chat EmitterWe're going to create a custom chat EventEmitter.Create a newEventEmitterobject and assign it to a variable called 'chat'.var chat = new E...
阅读全文
posted @ 2014-11-02 22:53
Zhentiw
摘要:1.2Hello YouLet's start with a simple Hello server. Follow the tasks below to create a simple Node server that outputs a greeting.First, tell the resp...
阅读全文
posted @ 2014-10-31 01:17
Zhentiw
摘要:After we installed the node.js, we run the cmd:npm installWhat happened is that, we get bower, karma,protractor andhttp-server module.check here:C:\my...
阅读全文
posted @ 2014-09-04 05:13
Zhentiw
摘要: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 th
阅读全文
posted @ 2014-08-01 01:59
Zhentiw
摘要:As we saw in the video, redis can do more than just simple key-value pairs. We are going to be using redis lists later to add persistance to our live-
阅读全文
posted @ 2014-07-31 23:52
Zhentiw
摘要: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 w
阅读全文
posted @ 2014-07-31 23:45
Zhentiw
摘要: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 b
阅读全文
posted @ 2014-07-31 18:03
Zhentiw
摘要: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. Re
阅读全文
posted @ 2014-07-31 17:47
Zhentiw
摘要: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 expre
阅读全文
posted @ 2014-07-31 17:09
Zhentiw
摘要:Let's create a page which calls the twitter search API and displays the last few results for Code School. The first step is to construct the proper UR
阅读全文
摘要: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 th
阅读全文
摘要: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 i
阅读全文
摘要: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.j
阅读全文
摘要: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
阅读全文
摘要:Add two dependencies to your package.json file, connect and underscore. You'll want to useconnect version 2.2.1 and underscore version 1.3.3. package.
阅读全文
摘要:Even though we knowpipedoes all the heavy lifting for us when dealing with backpressure, it's still a good idea for us to know about what is going on....
阅读全文
posted @ 2014-07-30 19:03
Zhentiw