Posts

Make clean file import and remove ../../ in node js Application

 In this section we will learn how to use modular apprach to ../../ remove from import file in node js Follow below steps ;- Install module-alias from below command -> npm install module-alias and in you package.json add this section ->  "_moduleAliases": {   "@src": "src",   "@prisma": "src/prisma",   "@modules": "src/modules" } after in your src/server.js add this line in top ->import "module-alias/register"; and now instead of this -> import prisma from "../../prisma/client.js"; you can use  import prisma from "@prisma/client.js";

Setup Server.js for Node Js Application

 In this post we will setup server.js file for our node js application. First go to backend/src/server.js file and write below code. -> import dotenv from "dotenv" import app from "./app.js" //because in package.json me type:module hai dotenv. config () const PORT = process.env.PORT || 5000 app. listen (PORT, () => {     console. log ( `Server running on http://localhost: ${ PORT } ` ) }) and save 

Creating App.js for Node Application

 In this post we will setup app.js file to make app running first write below code below ->  import express from "express" import cors from "cors" import morgan from "morgan" const app = express () app. use ( cors ()) app. use ( express . json ()) app. use ( morgan("dev") ) app. get ( '/' , ( req , res ) => {     res . json ({message: "CMS Backend API Running." }) }) export default app and save  express.json() — JSON body parse karta hai cors() — frontend (Next.js) ko API call karne deta hai morgan("dev") — console me request logs dikhata hai Base route / — test karne ke liye ready hai

Setup Prisma Client for Node Application

 In this post we will setup Prisma client for Node Application like below Fist go to backend/src/prisma/client.js and add below code on that -> import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); export default prisma; and save.

How to add Database Layer using Prisma in Node Application

 In this section we will add Database layer like Prisma in our Application so follow below steps. So Run these command to install Prisma related package. npm install @prisma/client iske run karne se package.json me dependencies me ye package aa jata hai. npm install -D prisma isko install karne ke baad dev dependencies me package.json me aa jata hai. @prisma/client runtime client hota hai (app me DB query ke liye) prisma CLI tool hota hai (schema manage karne aur migrate karne ke liye) After that we have to initilize prisma by using this command  npx prisma init is command se prisma folder me schema.prisma aur main root folder me .env filde ban jayegi. Express + Prisma, install these common industry-level dependencies: npm install bcrypt jsonwebtoken express-validator npm install dotenv cors morgan Dev dependencies- npm install -D nodemon after install nodemon add this script   "dev": "nodemon src/server.js" in package.json script Now you can use - npm run dev...

Start with Node Express Backend

 First Create a folder where you want to make backend and frontend Go to Backend folder and and run npm init -y this will create package.json file in your backend directory. Next step is in your backend folder install some package like below- express - Main backend framework cors - Cross Origin Resource Sharing (This will allow frontend for data) dotenv - .env file variable load karne ke liye body-parser - Request body json parse karne ke liye. Single command to install thease package- npm install express cors dotenv morgan body-parser after running above command package.json me dependencies section me ye package dikhenge.

WordPress Full Guide For Developer

WordPress Setup in Localhost The Famous loop in Wordpress for Generating posts Setting global Header and Footer in Wordpress Convert static HTML template into wordpress Interior Page Template Dynamic in Wordpress Display dynamic title in Browser tab for wordpress for every page Make manually menu links for wordpress Add homepage url in Header logo in wordpress Create parent and children page in Wordpress with BreadCrumb