Posts

Showing posts from January, 2025

MIddlewares in Express

  What is Middleware? Middleware in Express is like a security guard or helper that sits between the request (client) and the response (server) . It can modify, check, or handle requests before they reach the final destination (route handler). const express = require ( 'express' ); const app = express (); const port = 3000 const fs = require ( "fs" ) // Middleware function const logger = ( req , res , next ) => {     console . log ( `we are inside middleware` );     next (); // Move to the next middleware or route handler, if next() not written, req stop here..no further execution }; // Use middleware app . use ( logger ); app . use (( req , res , next ) => {     const timestamp = Date . now ();       const date = new Date ( timestamp );     console . log ( date . toString ());     fs . appendFileSync ( "logs.txt" , ` ${ date . toString () } is a ${ req . method } \n ` )   ...

BackEnd for WebDev

Image
 ye blog hinglish me likha gaya hai...jo samjh aaya uska bss notes hai BackEnd wali javascript: 1. Download NodeJs:  what is NodeJs;---- browser V8 engine,  Node.js is a runtime that lets you run JavaScript on a server to build fast and scalable web applications.  JavaScript talk directly to databases, files, and networks without needing a web browser. write this in terminal: npm init   [press enter] -->you can give project name, author etc,..to skip adding detail write {npm init -y} after this current folder.. becomes npm project, we can install packages..it becomes single entity,.. module/package -->borrowed code, written by someone else,..we are just importing to use it when you install any package,.. node_modules package appear in folder which holds packages and dependencies, helps to manage packages,...if node_modules  get deleted  "no worries"  dependencies are stored in package,json just write in terminal   [npm in...