Node.js

Sunday, April 13, 2014

Grab a reference to the controllers folder, call the init function on it and pass in the app, the server page only knows about initialization of main controllers


Create data directory and index file, type in this self executing anonymous function with methods yet to be created, get a list of the categories


Create seeddata file and add this javacript array to provide initial data


In the controller, grab a reference to the data folder, navigate up one


Invoke the getnotecategories method on the data object, supply the callback, the next function, in the render invocation, pass in both values as part of the model, databind aginst them both


In the view, if model returns error, spit out the error message to the screen


Type in this code, a foreach with a callback, for each item in the category display the name and count


Run the app, in the browser view the categories and count displayed


Create this public, css folder structure and add this css file, the color just off black


Reference the css file in the layout.vash, public folder is used and serache by convention from express


In server.js enable express to find the public folder, hence the css file


Run the app, view the new css applied


Install bower from the command line using npm, notice the -dev command, this saves this in a special way


In package.json view new section devdependencies, this means that it won't be pushed to a production server but only used in developement environment


Uninstall bower and reinstall bower with the dash g flag, that is globally, so all command shells on the machine can use bower


Install underscore using bower


Uninstall underscore temporarily using bower to configure file location so that we can use it in the project


Add this file and tell bower to install the components in this directory


Install underscore using bower again, view installed in public/lib folder


Add the script reference in the layout file, now every page hass access to underscore


Using Bower install bootstrap, the jquery bits are also pulled in


Reference bootstrap and jquery in the layout file


Bring in the bootstrap and theme css in the head


Replace the body with this boilerplate bootstrap code


Use bootstrap formatting for a listview render of the index page


Run the app and view the results in the browser


Install grunt, a task runner


Add this js file, type in this code, install the plugin nodemon


Extend configuration object passed in with named object named nodemon, the code says: start up script is server.js, if any change to a js file, restart, grunt is to speed up development


Tell grunt to load nodemon as a plugin, register default behavior, when grunt is run, run nodemon


Go into root directory and type grunt, starts the node server


Make a change in server.js file and save, view in nodemon restarting due to changes


Download the node-sqlserver-driver here


Drop the msnodesql folder into the project


The code to grab data from a local sql server database


Run the app, navigate to api/sql, view the json result of the query from the database


Download mongodb here


Copy contents of mongodb bin directory in new foder in project


Create folder to store data of database instance


Start the database server with path to data store


Default Success Warning Important Info Inverse
B S W I ? O