Skip to content

Htaung/Node-JS

Repository files navigation

Learn from The Net Ninja Youtube

https://www.youtube.com/watch?v=1US-P13yKVs

https://github.com/iamshaunjp/node-js-playlist https://stackabuse.com/learn-node-js-a-beginners-guide/ https://ilovecoding.org/courses/nodejs

downloaded at 35

https://www.youtube.com/watch?v=L4OP8JGKbQU&index=35&list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp

Learning end at 27

Learning end at 30 need to write the node for middleware and static resources

https://www.youtube.com/watch?v=9TSBKO59u0Y

node js is written in c++

heart of node js is V8 Engine V8 engine convert js code to machine code

Stream in node js

can create streams in node.js to transfer data increase performance

Installing express

npm install express

to installed in the module that we created in our web app go to that diretory and then type


npm init // that will create basic folder structure for web 
nmp install express -save // that -save option will add dependencies in package.json

if we add dependencies in package.json after that type in cmd
npm install 
it will install all dependencies required in our app

install nodemon ==> monitoring the changes of file realtime without having server to restart


npm install -g nodemon
nodemon app.js 

Express

Easy and flexible routing system integrates with many template engines contains a middleware framework

Responding to request
GET ==> app.get('route', fn)
POST ==> app.post('route', fn)
DELETE ==> app.delete('route', fn)

Installing Template Engine View Engine

like viewResolver in java tileViewResolver


npm install ejs -save

var express = require('express');

var app = express();

//set view engine like view resolver in spring tileViewResolver, app.set('view engine', 'ejs'); //by default template will look into /views folder

Installing static

Do not let your CDN betray you: Use Subresource Integrity https://hacks.mozilla.org/2015/09/subresource-integrity-in-firefox-43/

https://www.srihash.org/

Intall Mongo db

Create mlab account for mongo db it will give you free access with 0.5 gb free with cloud storage https://mlab.com/home?newDatabase=1

mongoosejs.com ==> object modelling tool

Learning socket.io in express

https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js