A very simple blog engine with Node.js, CoffeeScript, and Express.js
CoffeeScript JavaScript Shell
Failed to load latest commit information.
data Added some sample data generic data rather than site specific Oct 16, 2012
public new images Oct 1, 2012
routes Removed some site specific options. Removed blogRoutesTests since the… Oct 16, 2012
views Added some sample data generic data rather than site specific Oct 16, 2012
app.coffee Added authentication and authorization to the site. Oct 4, 2012
testSuite.sh Swapped TopicDataInMemory with TopicData (TopicData saves to text fil… Aug 7, 2012



A very simple blog web site using Node.js, CoffeeScript, and Express.js

This is a rough work in progress.

At this point there is code to handle a home page, an about page, a way to see a list of topics, and click on each topic to view the details of the post.

The data is kept in text files for now.


To run this code you need to have Node.js installed on your machine. If you don't have Node.js you can get it from nodejs.org

In addition to Node.js you'll need CoffeeScript. Once you've installed Node.js you can easily install CoffeeScript from the Terminal with the following command:

npm install -g coffee-script

CoffeeScript is a language that compiles to JavaScript. It allow us to write the code with a cleaner syntax than raw JavaScript. More info

Last but not least, you'll need to install Express and EJS by running the following command from the Terminal from inside the folder where you downloaded the source code

cd ~/dev/simple-blog
npm install 

Express is MVC-like JavaScript framework that takes care of the boiler plate code to handle HTTP requests and responses. More info

EJS is a template engine for Node.js used to generate HTML pages with dynamic content. More info

How to run the site

Once you've downloaded the source code and installed the requirements listed above, just run the following command from the Terminal window:

coffee app 

...and browse to your http://localhost:3000 You should see the rather anti-climactic web site with the beginnings of what will eventually be a blog engine. Enjoy it!

Structure of the source code

app.coffee is the main file. The rest of the code is organized as follow:

  • \models: CoffeeScript files with the models
  • \routes: CoffeeScript files with the controllers
  • \views: The views of the project (HTML + EJS)
  • \public: Static public files (client side JavaScript, CSS)
  • \util: Several small JavaScript utilities used throught the code
  • \data: Text files with the sample data
  • \data_test: Text files created when running the unit tests
  • \logs: Text files with the information logged when the app runs

The unit tests for the models and the controllers are on the same folder as the respective functionality (i.e. inside models and routes.) You can run the tests for each class individuall (e.g. coffee topicModelTest.coffee or coffee topicDataTest.coffee)

There is also a Bash shell script on the root folder (testSuite.sh) that runs all the unit tests at once.

Questions, comments, thoughts?

This is a very rough work in progress as I learn and play with Node.js.

Feel free to contact me with questions or comments about this project.