Created a Tips sections with helpful tips and advices
This commit is contained in:
10
README.md
10
README.md
@ -220,6 +220,14 @@ Recommended Client-Side libraries
|
||||
- [Color Thief](https://github.com/lokesh/color-thief) - Grabs the dominant color or a representative color palette from an image.
|
||||
- [Alertify.js](http://fabien-d.github.io/alertify.js/) - Sweet looking alerts and browser dialogs.
|
||||
|
||||
Pro Tips
|
||||
--------
|
||||
- When you install a new npm package, add a *--save* flag and it will be automatially
|
||||
added to `package.json` as well! For example, `npm install moment --save`.
|
||||
- Use [async.parallel()](https://github.com/caolan/async#parallel) when you neeed to run multiple
|
||||
asynchronous tasks, and then render a page, but only when all tasks are completed. For example, you might
|
||||
want to scrape 3 different websites for some data (async operation) and render the results
|
||||
on a page after all 3 websites have been scraped.
|
||||
|
||||
FAQ
|
||||
---
|
||||
@ -234,7 +242,7 @@ for each CPU detected. For the majority of applications serving HTTP requests,
|
||||
this is a resounding boon. However, the cluster module is still in experimental stage, therefore it should only be used after understanding its purpose and behavior. To use it, simply run `node cluster_app.js`. **Its use is completely optional and `app.js` is not tied in any way to it**. As a reminder, if you plan to use `cluster_app.js` instead of `app.js`, be sure to indicate that in `Procfile` if you are deploying your app to Heroku.
|
||||
|
||||
### Why Jade and not Handlebars template engine?
|
||||
When I first created this project I didn't have any experience with Handlebars. Since then I have worked on Ember.js apps and got myself familiar with the Handlebars syntax. While it is true Handlebars is easier, because it looks like good old HTML, I have no regrets picking Jade over Handlebars. First off, it's the default template engine in Express, so someone who has built Express apps in the past already knows it. Secondly, I find `extends` and `block` to be indispensable, which as far as I know, Handlebars does not have out of the box. And lastly, subjectively speaking, Jade looks much cleaner and shorter than Handlebars, or any non-HAML style for that matter.
|
||||
When I first started this project I didn't have any experience with Handlebars. Since then I have worked on Ember.js apps and got myself familiar with the Handlebars syntax. While it is true Handlebars is easier, because it looks like good old HTML, I have no regrets picking Jade over Handlebars. First off, it's the default template engine in Express, so someone who has built Express apps in the past already knows it. Secondly, I find `extends` and `block` to be indispensable, which as far as I know, Handlebars does not have out of the box. And lastly, subjectively speaking, Jade looks much cleaner and shorter than Handlebars, or any non-HAML style for that matter.
|
||||
|
||||
### Why do you have all routes defined in app.js?
|
||||
For the sake of simplicity. While there might be a better approach, such as passing `app` context to each controller as outlined in this [blog](http://timstermatic.github.io/blog/2013/08/17/a-simple-mvc-framework-with-node-and-express/), I find such style to be confusing for beginners. It took me a long time to grasp the concept of `exports` and `module.exports`, let alone having a global `app` reference in other files. That to me is a backward thinking. The `app.js` is the "center of the universe", it should be the one referencing models, routes, controllers, etc. When working solo I actually prefer to have everything in `app.js` as is the case with this REST API server for [ember-sass-express-starter's app.js file](https://github.com/sahat/ember-sass-express-starter/blob/master/app.js). That makes things so much simpler!
|
||||
|
Reference in New Issue
Block a user