This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I have worked with node.js for almost an year now, and have used it for following purposes. | |
| 1.To design commercial websites with simple 'user-form' submitting, and routing.All the processing is done in server side. | |
| 2.Critical applications , where most of the processing is done at the client-side. | |
| When working with node.js, it should be noted that it's a server-side platform. Node.js comes alogn with the Node Package Manager(NPM), s.t. | |
| all the NPM modules only support server side.If a user wants to run a javascript at the client side, he will have the following options. | |
| 1.Use Browserify to convert NPM server-side-compatible NPM modules to client-side-compatible NPM modules. | |
| 2.Use pure javascript files(without require() function) and store it tin the static folder , then call the pth of the static .js file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #use the following commnad to browserify .js files, which includes functions | |
| browserify main.js --standalone exampleFunction > bundle.js | |
| #when creatin main.js file the following format should be followed | |
| //--start | |
| module.exports = exampleFunction; | |
| function exampleFunction() | |
| { | |
| //--function body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // config/passport.js | |
| // load all the things we need | |
| var LocalStrategy = require('passport-local').Strategy; | |
| var mysql = require('mysql'); | |
| var connection = mysql.createConnection({ | |
| host : 'localhost', | |
| user : 'root', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mysql = require('mysql'); | |
| var connection = mysql.createConnection({ | |
| host:'localhost', | |
| user:'root', | |
| database:'mysampleDB' | |
| }); | |
| connection.connect(funcction(err){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #install MongoDB | |
| # install from this link 'https://www.mongodb.com/download-center?jmp=nav#community' | |
| #navigate to 'C:\Program Files\MongoDB\Server\3.4\bin' | |
| #open cmd, run following commands in the given order | |
| mongod | |
| mongo | |
| #if mongod is crashing, the reason is there's no folder to store databases.Type the following in the same root | |
| mkdir C:\data\db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #install express package globally | |
| npm install -g express | |
| #if the above commnand doesn't work try this | |
| npm install -g express-generator | |
| #go to your app dir | |
| #this will install express package in the local directory | |
| express |