Showing posts with label mongodb. Show all posts
Showing posts with label mongodb. Show all posts

Friday, 27 January 2012

Setting up my Node.js solution in Cloud9 IDE

Now where do we go after we have a brand new toy.. I just installed Cloud9 IDE.. see how-to install cloud9 here.

I want to setup a quick web app (really, really quick). I will time it.

00:00 - Get all my favourite (sounding) node modules from npm (presume you have npm) then use...
npm install  


See all the goodies I got.. note espresso took some time. Also look them up at http://search.npmjs.org/#/ 

00:09 - I had to install mongodb separately using (can also go here ..)

sudo apt-get install mongodb
00:18 - Created a folder at ~/devroot/MongoDb/data/db for my MongoDb instances. Now to run the db server..
mongod --port 9080 --objcheck --dbpath "devroot/MongoDb/data/db" --directoryperdb --rest
Note: --rest == RestApi, --directoryperdb == create a new dir for each new db's files
Success == MongoDb web console at http://127.0.0.1:10080/ (not so sure about the port, but trust that the mongod startup script should tell you your magic port number)



00:22 - Try out the mongodb server quickly...


mongo 
db.foo.save( some json object here );
db.foo.find()
 00:24 - setup that web app... hmm
Ok. Make sure you have done a global install of express using
sudo npm install -g express 
00:26 -  Use express to setup your solution structure inside your project root
sudo express  
cd   
npm install 
Note: this  installs default packages only so I had to get other ones here by
npm install
It uses  the cache (304) so it does not waste your time. I have now installed,
ejs, mongoose, colors.. (see list above)

Lets setup some routing .. see a good guide on expressjs here .. i am not re-inventing this.

Should be easy enough from here... good luck!