Skip to content

Sample code heavily based on the Professional Node JS book and the Secrets of the JavaScript Ninja book

License

Notifications You must be signed in to change notification settings

ashwinaggarwal/nodejs-professional

 
 

Repository files navigation

Sample code heavily based on the 'Professional Node JS' and the 'Secrets of the JavaScript Ninja' book

What is this?

Who are we?

  • We at ALT-F1 are studying those JavaScript technologies. We thought it was a simple way to

How much time?

  • We needed 5 working days to develop, understand, fine tune the code you have in front of you

Which tools have we used to code?

Early difficulties?

  • Jade scripts were very hard to understand
  • the debug of Jade is painful i.e. we lose too much time correcting tabulations vs. spaces !!!!
  • The syntax of JavaScript functions is quite unusual, hopefully the first chapters of Secrets of the JavaScript Ninja book are goldmine to understand them
  • the code of the Professional Node JS book doesn't fit today' versions of the tools which obliged us to debug the code
  • We didn't find a decent debugger (read visual) step by step of NodeJS scripts
  • Understand how Grunt works, but we have deleted this part of scripts for the moment

The future?

How to install?

Prerequisite

Check versions of your tools

  • on my computer (but other versions might work too ?!?
    • npm -v - use "1.3.5"
    • node -v - use "v0.10.15"

chap_20-HTTP_Middleware

  • run any node <name file>.js application
  • open the web browser on the right port, read the command line. e.g. http://localhost:<port>

chap_21-Express

  • npm install
  • grunt
    • see the Gruntfile.js for further documentation
  • node app
  • open the web browser on the right port, read the command line. e.g. http://localhost:<port>

chap_25-MongoDB

  • npm install
  • update ```app.js``file
    • update the line accordingly : var dbURL = 'mongodb://<login>:<password>@dharma.mongohq.com:<port>/<database name>';
  • node app
  • open the web browser on the right port, read the command line. e.g. http://localhost:<port>

JavaScriptNinja

  • based on the Secrets of the JavaScript Ninja book
  • Easy way to test assertions
  • standalone html pages including javascripts
  • open the web pages EqualityinJS.html
  • open the web pages HowFunctionsAreDeclared.html

Event-driven architecture

In event-driven programming you start by defining the code that will be executed when an event occurs, then put that code inside a function, and finally pass that function as an argument to be called later. See chapter 2 of the Professional Node JS book ... This shows that by using the closure pattern, you can have the best of both worlds: You can do event-driven programming without having to maintain the state by passing it around to functions. A JavaScript closure keeps the state for you.

Functional requirements

  1. you can login, logout
  2. you can delete a user from the database
  3. you can create a user

Technical requirements

Web application

  • Strict Model - View - Controller separation

  • Programming languages

  • Frameworks

CHANGELOG

v2013-08-11

  • add grunt to chap_21-Express

v2013-08-11

  • update the name of the directories
  • clean credentials
  • check package.json are correct
  • improve ergonomics of the application (e.g. display credentials available, improve error texts ...)
  • upload v1 on github

v2013-08-10 early morning

v2103-08-09

v2013-08-08 end of Ramadan

v2013-08-07

v2013-08-05

  • add test case using Karma
  • find/learn/implement many Grunt components

v2013-08-04

  • create "01.HTTP_Middleware" app
  • created hello_world_app' node displaying a simple "hello world"
  • Based on Professional Node JS book Part V "Building web application"
  • created reply_text module
  • create a middleware component that introduces a header into the response header section

About

Sample code heavily based on the Professional Node JS book and the Secrets of the JavaScript Ninja book

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • JavaScript 98.6%
  • CSS 1.4%