TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Aspects of Building a Node.js Application

65 pointsby gnwover 12 years ago

5 comments

jeswinover 12 years ago
First of all, nodejs is a great choice. Having to worry about just one programming language helps a lot. I'll add a few things I found out along my ongoing experiment.<p>1. Tests are essential in any project using a dynamic language; but don't write regular unit tests. Instead write a setup script. A script that sets up basic data in the store by calling various APIs. For example, setup your test users POSTing to /users. Whenever you need to go back to a clean database (which is, often) you can run this script. And of course, every time you want to test all the APIs.<p>2. Automate everything in scripts. Script your compile, test and deploy steps. Script emailing. Script your database backups, tar your image folders.<p>3. Refactor every time you get a chance. It is like having a bath. You feel like working on your app, code feels fresh.<p>4. Optionally, try coffeescript. The language often promotes good, declarative programming. Once you get used to the shorthand, you won't go back. Don't discard it after spending a couple of days on it; it might take a little longer depending on your experience level. Another minor benefit, since there is a compile step some typos are picked up by the compiler.<p>5. One of the big benefits of Node is that you could move things like rendering from server to the client (or the other way round) relatively easily. But still it is cleaner to just have REST services on the server and handle rendering on the client (with say, Backbone).
评论 #4982764 未加载
评论 #4982360 未加载
latchkeyover 12 years ago
In working with my app, I've found that Domains <a href="http://nodejs.org/api/domain.html" rel="nofollow">http://nodejs.org/api/domain.html</a> are crucial for wrapping 3rd party async code that can crash on errors.
评论 #4982795 未加载
评论 #4982531 未加载
cjfontover 12 years ago
It's probably worth pointing out that there is now an increasing trend toward higher level frameworks like Meteor and DerbyJS which help blur the lines between the server and client and simplify the creation of real-time apps. I think in a couple more years they will start to replace Express as the de facto framework to use for medium to large sized projects.
hackerboosover 12 years ago
Can't you just use Fabric or Capistrano for deployment?<p>I can't believe I used to SSH into my server to restart an app when I can now just run `cap unicorn_APPNAME:restart`
评论 #4982358 未加载
KaoruAoiShihoover 12 years ago
Why mention newrelic, doesn't even integrate into nodejs.
评论 #4982526 未加载