Bootstrap is an amazing set of pure CSS3 / HTML 5 components, while EmberJs amazes in its beauty of
making web applications right.
You can just hook both projects together by using Bootstrap as is in Handlebars templates,
But soon enough, you will find yourself asking questions sucha s:
How do I interact between Bootstrap events and Ember (such as Controllers)?
How to pass Bootstrap components data from Ember (such as Controllers)
I’ve seen few options about the integration between both, but:
They are not easy and fun to use, they make the ease of Bootstrap too complex.
They are not well documented.
Development is too slow, I haven’t seen anything new lately.
So! I’m excited about a project I’ve been working lately with some guys to integrate Bootstrap & EmberJs together in a way that
doesnt make Bootstrap usage more complex than using it as-is but providing great integration with EmberJs components.
I’ve been struggling lately to find an appropriate way to handle models correctly,
In one hand, these noSQL DBs such CouchDB have great flexibility and I didn’t want to ruin that with a blowing up ORM framework,
in the other hand once the application grows a little bit more than a contact list app, then things become messy.
While writing a larger app with Node, I find myself struggling with finding solutions to problems such:
(there are few more but these are the main)
Validating a document (model) properties (application level) before storing it in the DB.
A minimal schema where each attribute is defined per model to ensure no allowed attributes leaks into the model.
Automatically convert a property value when a value is set.
Filter critical, sensitive attributes when transfering the model on the wire to external clients.
Updating an existing domain via an accessibility-aware method (you may want users to update their profile but not letting them directly change their password attribute)
We would like to have nodejs to start automatically as a service, to do so, lets create an init.d file
Note: you have to change the properties in the file such as yourappuser, myapp to your app folder and server.js to your node app file.
Add execution permission to the nodejs init script
sudo chmod +x /etc/init.d/nodejs
Pre Routing to port 80
Linux does not allow non super users to listen to ports < 1024, assuming your application listen to port 8080,
You would probably like to pre route any traffic arriving from port 80 to your node app that listens to port 8080
You can do this by the pre routing nat capability of Iptables
chkconfig iptables on
service iptables start
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443 #if you want SSL tooservice iptables save
It is common to install http proxies such as nginx on front of nodejs,
This architecture has many advantages such as raising security level, listening natively to port 80, load balancing, multiple node apps support
via url rewrite, etc…
build-couch uses not an official Mozilla SpiderMonkey version, but considered to be very stable,
if you would like to replace it with other versions then do the following,
You can safely skip this, proceed only if you have a good reason to do so
sudo yum install mercurial
cdhg clone --verbose http://hg.mozilla.org/releases/mozilla-release
hg checkout FIREFOX_XX_0_RELEASE --clean #replace XX with the tag you wishrm -rf ~/build-couchdb/dependencies/spidermonkey/js
rm -rf ~/build-couchdb/dependencies/spidermonkey/mfbt
cp -r js mfbt ~/build-couchdb/dependencies/spidermonkey
Building CouchDB and its dependencies
Now lets build Couch, you can replace 1.3.1 with any CouchDB release you wish to build,
Or change the installation location.
if[ ! -e "/etc/logrotate.d/couchdb"]then# add couch.log to logrotate sudo ln -s /usr/local/couchdb/etc/logrotate.d/couchdb /etc/logrotate.d/
# change to daily rotation sudo sed -e s/weekly/daily/g -i /usr/local/couchdb/etc/logrotate.d/couchdb
#logrotate -v -f /etc/logrotate.d/couchdb fi
Run CouchDB on startup
# run couchdb on startupsudo ln -s /usr/local/couchdb/etc/rc.d/couchdb /etc/init.d/couchdb
sudo chkconfig --add couchdb
sudo chkconfig --level 345 couchdb on
sudo service couchdb status
#Apache CouchDB is not running.sudo service couchdb start
#Apache CouchDB is running as process 5047, time to relax.
[ec2-user@ip ~]$ cd ~
[ec2-user@ip ~]$ git clone https://github.com/apache/couchdb.git
[ec2-user@ip ~]$ cd couchdb
[ec2-user@ip ~]$ git checkout -b 1.3.1 1.3.1
[ec2-user@ip ~]$ ./bootstrap #should output: You have bootstrapped Apache CouchDB, time to relax.[ec2-user@ip ~]$ ./configure --with-erlang=/usr/lib64/erlang/usr/include --with-js-lib=/usr/local/lib/ --with-js-include=/usr/local/include/js/ #should output: You have configured Apache CouchDB, time to relax.[ec2-user@ip ~]$ make
[ec2-user@ip ~]$ make test[ec2-user@ip ~]$ make install
Note: you can of course replace 1.3.1 tag with the latest stable version if there’s any.
Hey, we’r almost done, lets configure the environment.
Create a couch user
For security reasons, create a dedicated couch user and correct files ownership and permissions: