Sample code heavily based on the 'Professional Node JS' and the 'Secrets of the JavaScript Ninja' book
- useful to learn NodeJS and how to write simple Create/Retrieve/Update/Delete applications
- web apps using NodeJS, Jade, Express, Async and MongoDB
- tooling uses Grunt, Grunt-cli and Grunt-init
- heavily based on the Professional Node JS book and a bit of help from the Secrets of the JavaScript Ninja book
- We at ALT-F1 are studying those JavaScript technologies. We thought it was a simple way to
- We needed 5 working days to develop, understand, fine tune the code you have in front of you
- in a first stage we have used Sublime Text 2
- then we moved to WebStorm IDE at the very last stage due to our inability to debug Jade scripts
- 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
- Use Grunt, Jasmine, Istanbul, Karma, Mocha and many others to operate the code and run a standard software-engineered' company
- on my computer (but other versions might work too ?!?
npm -v
- use "1.3.5"node -v
- use "v0.10.15"
- run any
node <name file>.js
application - open the web browser on the right port, read the command line. e.g.
http://localhost:<port>
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>
npm install
- update ```app.js``file
- update the line accordingly :
var dbURL = 'mongodb://<login>:<password>@dharma.mongohq.com:<port>/<database name>';
- update the line accordingly :
node app
- open the web browser on the right port, read the command line. e.g.
http://localhost:<port>
- 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
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.
- you can login, logout
- you can delete a user from the database
- you can create a user
-
Strict Model - View - Controller separation
-
Programming languages
- Javascript v1.8 (I guess)
-
Frameworks
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
- the code is up and running
- the search articles functionality should be called like this '''http://localhost:3000/articles/search?q=
- todo: add a search box inside the header
v2103-08-09
- Starts Professional Node JS book chapter 25: Connecting to MongoDB Using Mongoose
- create "03.Express_app mongodb" app
- add article data model and functionalities - see page 341 "Referencing Other Documents Using DB Refs"
v2013-08-08 end of Ramadan
- Successfully end the chapter 21 of the Professional Node JS book: Making a Web Application
v2013-08-07
-
work on chapter 21 of the Professional Node JS book: Making a Web Application Using Express
- many issues appear as
- Professional Node JS book is incorrect and documentation of Jade is very poor
- Professional Node JS book is based on Express 2x and I use Express 3x
- some requirements
- many issues appear as
-
Complete chapter 20 of the Professional Node JS book: Building and Using HTTP Middleware Connect
-
starts chapter 21 of the Professional Node JS book: Making a Web Application Using Express
-
create "02.Express_app" app
-
Use of Jade node template engine
v2013-08-05
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