Lets make a Twitter Clone in Node.js

On March 5, 2011, in Web, Web Coding, by admin

During last few weeks I’ve promised many (mostly from HackerNews) that I would publish and open source an example application in Node.js using some of the techniques I’ve talked about. While in need of a little intellectual diversity from my normal role working 24/7 on my startup (http://www.exipe.com) I decided that making a twitter clone would be cool.

This morning I purchased the domain name nodrr.com (instead of tweet you nod … if that makes any sense … kind of a play on node.js + twitter + some physical action) for this purpose. It’s currently just after 4:15 PM on Saturday afternoon the East Coast of the US, I just went out Thursday night for a bit with friends so I’m not feeling all socially isolated by this, I just watched The Social Network (inspiration) and I’m feeling the need to code … lets make a Twitter clone in node.

I’ll be live blogging the whole time with edits, updates and battleplans. Please forgive my lack of attention to grammar/spelling/common sense English writing skills as I’ll be focusing on coding, not so much whether that use of ellipsis was correct. Watch my coding progress on github as well if you’d like: https://github.com/tglines/nodrr

4:25PM – First things first:

  • Set up EC2 Micro Instance with Ubuntu 64-bit
  • Set up git/github link on the EC2 instance
  • Download and install Node.js, npm and some of the libraries I’ll be using
  • Provision an AWS elastic IP and point nodrr.com at my EC2 instance

4:40PM – Box is up:

  • EC2 is up, dns records are pointed to the elastic IP and we’re SSH’ed In
  • Compiling node

5:10PM – Git project initialized, node built, npm installed.

  • Grabbed express, connect-auth, mongoose, jade for now from npm
  • Now installing mongodb packages
  • Cue the Daft Punk
  • Vote for the news item on HackerNews ;-)

5:35PM – Project directories setup, main script started … getting an unexpected error

  • Grabbed a few more npm libs – connect-mongodb and connect-force-domain
  • Getting and error with express.bodyDecoder() … hmmm

5:50 PM – Theres the bug … connect renamed bodydecoder to bodyparser

6:05 PM – Facebook Connect Setup

  • Got oauth through npm
  • Set up the app on facebook
  • Jade template isn’t getting the title ….

6:10 PM – Battling a new one

6:23 PM – Hello World

  • Got a hello world up (taking down now so dont check yet)
  • Fixed the express.js local variable passing change … see my error above about the title
  • Lets start putting in some real stuff here … auth/login … forms … all the good stufff

6:40 PM – Some Frontend

  • Added a reset style sheet from yahoo and included style.css
  • Included jquery from google’s cdn and a template main.js

6:55 PM – Dinner Break

  • Be back in a bit

7:10 – Back @ it

  • The buffalo chicken/cuscus was very tasty.
  • Lets do a color scheme like: http://nodejs.org/
  • Working on facebook login auth … we’ll later add more providers like twitter/github/google etc

7:30 PM – Once More Into the Breach

  • Now Getting this error on redirect attempts: Error: Can’t set headers after they are sent.
  • hmm…

8:10 PM – Redirect Problem = Solved For Now

  • The redirect problem with facebook connect has now been solved
  • After initial login with connect throwing the user to a make a username page.

8:45 PM – We Have Nods!

  • The first nods are going in the database now, some serious securing to do
  • Heres a screenshot:

9:05 PM – Stylin

  • A little more style:

11:22 – Another Screenshot

  • User Pages Much Better
  • Need Pagination and character limits
  • Screenshot:

12:18 – Check it Out: http://www.nodrr.com

  • It works pretty decently but needs a lot of features to be more usable
  • Please keep in mind that this was just a demo and proof of concept
  • Check out my real startup @ www.exipe.com
  • Time for bed.
Be Sociable, Share!

17 Responses to Lets make a Twitter Clone in Node.js

  1. Joan says:

    woot, good luck! Let’s see how long it takes to you build it.

  2. Joan says:

    You know, you could use nodester.com for hosting (if you have an account), it’s quite easy and straightforward to push changes and deploy it, it might make it easier to live-develop.

  3. HC says:

    Good luck! :)


    What is the best/recommended way to run Node.js on port 80 with EC2? I deployed my fist weekend Node.js project today and used this solution: https://gist.github.com/776580. It works but I don’t know, if this is the right way to do it.

  4. johans says:

    @HC – I had the same issue/question and some discussion with folks over at DailyJS. I ended up using Nginx as proxy to my node app running on 8080.

    It just seems wrong to me – Node is great for making servers why stick it behind another server. I also setup on No.de and it works directly on port 80.

    Alex Young of DailyJS tweeted TJ Holowaychuck about deploying Express apps and he said no Nginx or anything.

    Alex has been thinking about using authbind.

  5. admin says:

    I’m not planning on running it behind anything and really don’t like the idea of putting another layer in front of it to slow things down.

  6. johans says:

    Connect / Express – yes problem due to connect 1.0.0 changing bodyDecoder() to bodyParser(). I believe TJ has fixed in latest beta of Express – if you check package.json for connect versions

  7. Using Express and Mongoose really interested in how you run tests against a test database.

  8. Benji Orozco says:

    Good luck, following the blog updates!

    BTW, I wonder if your startup’s logo (exipe.com) got some inspiration from Arch’s Linux logo (http://www.archlinux.org/art/)

  9. admin says:

    We’ve actually noticed the similarity and are modifying the logo on Exipe, thanks!

  10. Simon Hamp says:

    All the best Travis!! This looks like an awesome idea. Might give it a go myself sometime.

  11. Aaron says:

    I’m not sure exactly what’s up, but on the return from facebook auth.. It just returns with a page not found.

    Looks really cool though! excellent work for just a few hours

  12. DanBUK says:

    Seeing this post meant I coded a similar thing using CouchDB instead. Code isn’t up yet.


  13. For a study, addressed the issue very well. I have the problem has obviously been interested in the subject after google search. Absolutely necessary for guaranteed learning archive. Thank you.

  14. Robb says:

    didn’t work for me :(

  15. Jack Moyes says:

    Nicely explained post. But for me its easy and helpful that we buy Twitter Clone script from web development Company. And also as I can see its not working for some users.

  16. genewitch says:

    How did you track your time? Please tell me you’ve an automated way?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>