Nodejs
This post is just for making notes during my learning of Node.js through various courses and online material. This will be always a work in progress blog post
Node.js is an open source server side runtime environment, which is cross platform.It uses Javascript as its language
check node version
node --version
Making web request in Node we can make webrequest by using inbuilt http or by using ‘request’ example : For making web request by http
1 2 3 4 5 6 |
|
example: Please note that there is no space between key and : while defining options
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Example: We can simply by giving GET . There is no need to close request since we are not going to send any more information to request
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Another option is
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Starting with Node.js and Express
1
|
|
Above command will create a package.json. Leave details are default or change accordingly
1
|
|
Above will install express and also add it as dependency in package.json
1
|
|
Above will create a app.js file. In package.json add below
1 2 3 4 |
|
Now, if we run “npm start” from command line, it will run app.js
Bower
Package manager for web/front end. It is installed with NPM and have flat package hierarchy(doesnt install dependency underneath one level) .It works similar to NPM and have Bower.json for dependency managament.
Create a .bowerrc file and have project specific settings. Now move the components from bower_component to public folder defined earlier. update .bowerrc with below
1 2 3 |
|
now run below
1 2 3 4 |
|
Gulp
It is a task manager for web projects. It have code based config. It is packaged base so that we can use different external packages
Mongo DB
- Install MongoDB from website
- mongoD is command for running server
- mongo is command for running another terminal for interacting with mongo db
- show dbs will show list of db
- Install MongoDB Node.js driver using NPM ```