Posts

Express res.send

Once res.send() is used  no further operations are sent console.log can be used multiple times but res.send can only be used once  const express = require ( "express" ); const users = require ( "./MOCK_DATA.json" ); const app = express (); const PORT = 3000 ; app . use (   "/hi/:id" ,   ( req , res , next ) => {     console . log ( "HELLO " );     next ();   },   ( req , res , next ) => {     console . log ( "Hellow 2" );     next ();   } ); app . get ( "/hi/:id" , ( req , res , next ) => {   res . send ( req .params.id); }); app . listen ( PORT , () => {   console . log ( "server is running at port" + PORT ); });

Psostgress SQL

 1 To create database     create database database_name; 2 To show all the database     show databases; 3 To use/select the database     use database_name; 4 to show the available tables     show tables; 5 to create the table     create table table_name( the columns with their type);     Eg:     create table coffee_table(id int , name varchar(250) , country varchar(250) ); 6 To show the contents in the table     descirbe table_name; 7 To add contents to the table     insert into table_name values (1 , "Ram" , "USA" ); 8 To select all the data from the table     select * from table_name; 9 To select specific parameters/columns from table     select column_name from table_name;      Eg:     select name from coffee_table; 10 To select/display specific data with certain values from table     select * from table_name where column = "value"; ...

Introduction to Node Js

 Node Js is a runtime environment for JavaScript. node --version : check version of node npm -v :check version of npm npm init : package.json FILE HANDLING In file handling an package is required called fs (file system) ASync operation/requests are non blocking requests Sync operation/requests are blocking requests In Url; + afai space hunxa install npm url to seprate protocols, domains,parameters , query etc. Query starts from ? and separated from &