Posts

Showing posts from December, 2022

Show name using php

  <?php $str = "rupesh";  $strLength = strlen($str); for($i=0; $i<=$strLength; $i++){  for($j=0; $j<$i; $j++){  echo $str[$j];  }  echo "<br/>"; } ?> <!DOCTYPE html> <html> <body> <?php $str2 = "Rupesh"; $strlength = strlen($str2); for($i=$strlength; $i>=0; $i--){ for($j=0; $j<=$i; $j++){   echo $str2[$j];      } echo "<br/>";        } ?> </body> </html>

How to make a pyramid in core php .

 <!DOCTYPE html> <html> <body> <?php $n=4; for($i=1;$i<=$n;$i++){ for($j=1; $j<=(2*$n)-1; $j++){ if($j>=$n-($i-1) && $j<=$n+($i-1)) { echo "*"; }else{   echo "&nbsp;&nbsp;"; } } echo "<br/>"; } ?> </body> </html>

Make a page for title of YouTube.

JWT Middleware Authentication API In Node, Express JS, and MongoDB

 1. auth.js const jwtkey = require ( "jsonwebtoken" ); const config = require ( "../config/config" ); const verifyToken = async ( req , res , next ) => {     const token = req . body . token || req . query . token || req . headers [ "authorization" ];     if (! token ){         res . status ( 200 ). send ({ success : false , msg : "A Token is required for Authentication." })     }     try {           const decode = jwtkey . verify ( token , config . secret_key );           req . user = decode     } catch ( error ){         res . status ( 400 ). send ( error . message );     }     next (); } module . exports = verifyToken ; 2. config.js const config = {     secret_key : "Thisisasecretkey." } module . exports = config ; 3.userController.js const User = require ( "../models/userModel" ); const ...

Login RestFul API With JWT Auth Token In Node, Express JS, and MongoDB

 1. Index.js const express = require ( 'express' ); const mongoose = require ( 'mongoose' ); const app = express (); mongoose . connect ( "mongodb://127.0.0.1:27017/ECOM" ) //load routes const user_route = require ( "./routes/userRoute" ) app . use ( '/api' , user_route ) app . listen ( '3000' ,() => {     console . log ( "Server Connected Successfully.." ) }) 2. Config.js const config = {     secret_key : "Thisisasecretkey." } module . exports = config ; 3. Controllers const User = require ( "../models/userModel" ); const bcryptjs = require ( "bcryptjs" ); const jwtkey = require ( "jsonwebtoken" ); const config = require ( "../config/config" ); const create_token = async ( id ) => {   try {     const token = await jwtkey . sign ({ _id : id }, config . secret_key );     return token ;   } catch ( error ) {     res . status ( 400 ). send ( ...

Register RestFul API With File Upload In Node, Express JS, and MongoDB In Hindi

 1. index.js  / (app.js) const express = require ( 'express' ); const mongoose = require ( 'mongoose' ); const app = express (); mongoose . connect ( "mongodb://127.0.0.1:27017/ECOM" ) //load routes const user_route = require ( "./routes/userRoute" ) app . use ( '/api' , user_route ) app . listen ( '3000' ,() => {     console . log ( "Server Connected Successfully.." ) }) 2. Models const mongoose = require ( 'mongoose' ) const userSchema = mongoose . Schema ({     name : { type : String , required : true , trim : true },     email : { type : String , required : true },     password : { type : String , required : true },     image : { type : String , required : true },     mobile : { type : Number , required : true },     type : { type : Number , required : true } }) module . exports = mongoose . model ( "User" , userSchema ) 3. controllers const User = require ( '../models/userModel...

React function component.

  import React from "react" //Make arrow function const Student = props => {     return < h1 > Hello How are You ?? { props . name } </ h1 > } export default Student

React Fragement example

  import React , { Component , Fragment } from "react" ; class App extends Component {   render () {     // return React.createElement("h1",null, "Hello Geeky shows..");     return (         //Using Fragment : is m hum multiple element  use kar sakte hai.     //   <Fragment>     //     <h1>Hello Geeky Shows .</h1>     //     <h2>Hillo again baby.</h2>     //   </Fragment>     // <> and </> is use instead of fragment tag.     <>     < h1 > Hello Geeky Shows . </ h1 >     < h2 > Hillo again baby. </ h2 >     </>     );   } } export default App ;

Make api in express js

 1. app.js import express from 'express' import connectDb from './db/connectdb.js' import web from './routes/web.js' const app = express () const port = process . env . PORT || '3000' const Database_url = process . env . Database_url || "mongodb://localhost:27017" //json app . use ( express . json ()) connectDb ( Database_url ) app . use ( '/student' , web ) app . listen ( port ,() => {     console . log ( 'Server Connected Successfully.' ) }) 2.web.js import express from 'express' import studentController from '../controllers/studentController.js' const router = express . Router () router . get ( '/' , studentController . getAllDoc ) router . post ( '/' , studentController . createDoc ) router . get ( '/:id' , studentController . getSingleDocById ) router . put ( '/:id' , studentController . updateDocById ) router . delete ( '/:id' , studentCont...