Posts

Standard Way To Create React JS Fresh Project

Image
As you know in programming world  JavaScript  is becoming quite famous programming language so in this blog we will discuss how we can create fresh project of  ReactJS  in standard way. React JS - Education Funda ~ $ npx create-react-app folder-name ~ $ npx create-react-app folder-name --template typescript To do setup of license, .gitignore and code of conduct for new project we can do with NPX commands: ~ npx license mit (it will create open source license for your project) ~ npx gitignore node (it will create .gitignore file in your project automatically so you don't need to create it manually)  ~ npx covgen your_email_id (it will create code of conduct file for your project)

Merge Multiple PDF Buffers in Node JS

Image
Let's See How We Can Merge PDF Buffers in Node JS with "pdf-merger-js" PDF Merger JS - Education Funda For merging pdf buffers we should firstly have the buffers of each pdf and we can run loop than can add each buffer for create one single merge buffer. If You Have HTML Files Which You Want to Convert to PDF Buffer and Create 1 Single Merge PDF const getNoticesPreview = async (req, templateId ) => { const caseIdsArr = req. body . caseIds . split ( "," ); var merger = new mergePdfs (); for ( let i = 0 ; i < caseIdsArr. length ; i ++ ) { let caseId = caseIdsArr[i]; let caseDetails = await caseService. getCase (caseId); let templateDetails = await templateService. getTemplate ( templateId ); let options = { format : 'A4' }; let compiled = ejs. compile (fs. readFileSync ( __dirname + 'public' + templateDetails. templateFile , 'utf8' )...

Deploy NodeJS Project in Ubuntu Server

Image
Let's See The Standard Way To Deploy NodeJS  Project with Nginx  Firstly I assume you already connected to your Ubuntu server. Now first command which you need to run is ~ sudo apt-get update (This command will update all default packages of ubuntu server with latest versions) Now let's install Nginx server ~ sudo apt install nginx Now you have to install Node JS and NPM (Please read this article for it) Now you can check with ~ nginx -v ~ node -v ~ npm -v  NodeJS - Education Funda In each above commands version should be written if not it means it not installed properly in your server. now go to cd /var/www directory -> From here create directory sudo mkdir domain.xyz . -> cd domain.xyz . From here take clone from your GIT branch ( Reference Link ) Now go to ~ cd yourCloneDirectory . -> From this directory just run your project ~  node app.js/server.js (your root file of node js project) Now just call your IP or Domain in your browser your project should...

Git Clone From Specific Branch

Image
For clone code from specific branch we can use below command: GIT - Education Funda - git clone -b branchName cloneUrl  Lets see some of the top and most commonly asked interview question related to GIT . I hope this quick tip will be helpful for you. Happy Coding !!

Installing Node.js in Ubuntu Server PPA

Image
Installing Node.js in Ubuntu Server with Apt Using a NodeSource PPA Node JS Installation - Education Funda To install a different version of Node.js, you can use a PPA (personal package archive) maintained by NodeSource. These PPAs have more versions of Node.js available than the official Ubuntu repositories. Node.js v14, v16, and v18 are available as of the time of writing. First, we will install the PPA in order to get access to its packages. From your home directory, use curl to retrieve the installation script for your preferred version, making sure to replace 18.x with your preferred version string (if different). curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh --------------------- You can inspect the contents of the downloaded script with nano (or your preferred text editor): nano nodesource_setup.sh ---------------------------- Running third party shell scripts is not always considered a best practice, but in this case, NodeSource implements their own logi...

Loading GIF Loader In Center of Webpage

Image
While page is loading sometimes it takes too much time for that time duration we can show GIF loader or any kind of loader to the users so users can know easily something is happens. Add Loader To Your Webpage   Such as your webpage html code is like below: <body>     <div class="content">         Long Content Here         <br/>         Click to view loading image.     </div>     <div id="divLoading" style="display:none">     </div> </body> We added one div here with the ID divLoading, you can take any ID selector as per your need. Now in webpage you need to add css code so that loader can be show in center of page at any screen size: <style type="text/css">      #divLoading.show      {          display : block; ...

Node JS Convert 404 API Route to Proper Message

Image
We Generally Face A Problem of Bad Error Handling If Route Not Found in Node JS, Let's See How Can We Fix This Error Handling in Node JS Via adding below 4 lines code in our main node js file, we can manage it easily: //404 error handling app . use (( req , res ) => { const error = new Error ( "Not found." ) req . code = 1 req . statusCode = 404 ResponseMiddleware ( req , res , error . message ) }) That's it ! Happy Coding !