Building a MEEN Blog: MongoDB + Express + Ember.js + Node

Today we are going to build a blog. Not just any blog, but a MEEN blog. What is a MEEN blog you ask? Well why don’t you just keep on reading, instead of asking questions to no one in particular.

MongoDB
The MongoDB downloads page does not provide any command-line friendly links or instructions to download their product. Luckily there was this: Install MongoDB on Linux which has a command-line friendly approach to download the latest version of MongoDB. Perfect.

$ curl -O http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz
$ tar zxvf mongodb-linux-x86_64-2.6.4.tgz
$ cp -R mongodb-linux-x86_64-2.6.4/ ~/mongodb
$ echo 'export PATH=$HOME/mongodb/bin:$PATH' >> ~/.bashrc
$ . ~/.bashrc
$ sudo mkdir -p /data/db
$ sudo chown -R bttf:bttf /data  #we will be running mongod under 'bttf' user

The instructions are pretty straightforward. I created a ‘mongodb’ directory in my home folder, and created ‘/data/db’ that mongod will be using to store its data, with the correct file permissions.

Node
Before we get started with building our API with Express, we are going to need to install node.

I prefer installing node locally via one of these methods. Doing this will avoid a mess of permission problems you may encounter when using globally installed node modules, especially when modules require global installation. Global installs go into a directory in your home folder (which should be included in your path) and you will not have to use sudo –ever–. This saves keystrokes and is also a safer way to operate in Linux.

(You can ignore the curl request to npmjs.org; npm is now included with node.)

Express
I am going to use the Express Application Generator. With it you can run ‘express [dir name]‘ and it will scaffold out an express app. You will need to navigate into the directory and run ‘npm install’.

The first thing we want to do is install mongoose, which basically acts as our ORM for accessing our mongo database from our Express app.

npm install -S mongoose

http://emberjs.com/api/data/classes/DS.RESTSerializer.html#property_primaryKey

Ember – Creating new records and storing them, etc …

http://discuss.emberjs.com/t/why-does-store-createrecord-create-a-record-immediately/3161/5

Ember – Attaching multiple routes to a single controller

http://discuss.emberjs.com/t/is-it-possible-for-many-routes-to-share-the-same-controller/2160

Ember – Make sure API returns JSON for POST requests as well…

http://discuss.emberjs.com/t/what-should-an-api-compatible-rest-server-return/779

http://stackoverflow.com/questions/18671265/duplicate-null-id-records-in-ember-data