Install necessary packages like apollo-server-express and graphql using npm or yarn. Create a schema using the GraphQL Schema Definition Language (SDL). Define types, queries, mutations, and subscriptions. Write resolver functions to handle GraphQL queries, mutations, and subscriptions. Resolvers resolve the data for each field in the schema. Configure and start the Apollo Server with Express.… Continue reading Node Js GraphQL Basis
Author: Bibin Johnson
How to create a REST API with Node.js and Express
to create the REST APIS in the node application Creating a folder structure Open image-20240422-093737.png ├── config/ └── db.js ├── models/ └── Student.js ├── routes/ └── studentRoutes.js ├── controllers/ └── studentController.js ├── app.js └── package.json app.js File const express = require(‘express’) const app = express(); const Student = require(‘./models/student’) const mongoose = require(‘mongoose’); const studentRoutes… Continue reading How to create a REST API with Node.js and Express
Node Js Mobile OTP based authentication and authorization API using Nodejs and Mongodb
Dependencies 1) Express Js Express is a back end framework for Node.js.It is designed for building web applications and APIs. It has been called the de facto standard server framework for Node.js 2) Mongoose Mongoose is a Database ODM for Nodejs. It provide schema based api to model our mongodb schema.It is famous in world… Continue reading Node Js Mobile OTP based authentication and authorization API using Nodejs and Mongodb
Creating Simple Node js Application
Creation of a simple node js application Installation and connection with DB Basic Commands used for the installtion Starting the application To install a basic simple app for node firstly need to check the node version on the system If node is not installed check the following documents for the node installation Node.js — Download… Continue reading Creating Simple Node js Application
Adding .env file to access to all components and pages in Next JS 14
NEXT_PUBLIC_WORDPRESS_GRAPHQL_ENDPOINT=https://jjrevamp.jjecom.com/graphql/ To access this URL in all pages we need to add NEXT_PUBLIC_SOMETHING THis will enable to call the URL in any pages Calling the posts using GRaphQL API onst client = new ApolloClient({ uri: process.env.NEXT_PUBLIC_WORDPRESS_GRAPHQL_ENDPOINT, cache: new InMemoryCache() }); const graphqlEndpoint = process.env.NEXT_PUBLIC_WORDPRESS_GRAPHQL_ENDPOINT; console.log(“Graph URL”, graphqlEndpoint); const FetchPosts = () => { const [posts,… Continue reading Adding .env file to access to all components and pages in Next JS 14
Skeleton Structure in Next jS
Skeleton is a placeholder to show a loading state and the expected shape of a component. Firstly Need to import the module import {Skeleton} from “@nextui-org/react”; Code for the skelton loading and loaded state with condition import React from “react”; import {Card, Skeleton, Button} from “@nextui-org/react”; export default function App() { const [isLoaded, setIsLoaded]… Continue reading Skeleton Structure in Next jS
Fetching Data on the Server with fetch
Next.js extends the native fetch Web API to allow you to configure the caching and revalidating behavior for each fetch request on the server. React extends fetch to automatically memoize fetch requests while rendering a React component tree. You can use fetch with async/await in Server Components, in Route Handlers, and in Server Actions. async function getData() { const res = await fetch(‘https://api.example.com/…’) // The return value is *not*… Continue reading Fetching Data on the Server with fetch
Dynamic Routes in Next JS
This is about how to assign the pages dynamically from each API Creating a static page for calling the single landing page This is an example of the folder structure for the dynamic pages <Link key={index} href={`/case-study/${category.slug}`}> <div> <p className=’jjrewamp-casestudylistpage-secondsection-first-filter-list-category-1′>{category.name}</p> </div> </Link> This is call to the casestudy page inner page <Link href={`/case-study/${category_slug}/${caseStudy.post_name}`}><h3 className=”jjrewamp-casestudylistpage-secondsection-categorysection-title-h3″>{caseStudy.post_title}</h3></Link> here… Continue reading Dynamic Routes in Next JS
Next js Authentication by credentials using APP ROUTER Method
Create .env file with the following domain URL like NEXTAUTH_URL=http://localhost:3000/ Create the route.js file app/api/auth/[…nextauth] in the following path import NextAuth from “next-auth/next”; import CredentialsProvider from “next-auth/providers/credentials”; import GoogleProvider from “next-auth/providers/google”; export const authOptions = { providers: [ CredentialsProvider({ name: “Credentials”, credentials: { username: { label: “Username”, type: “text”, placeholder: “User Name” }, password: {… Continue reading Next js Authentication by credentials using APP ROUTER Method
How to add custom tab in Customer Account Sidebar Magento 2
First of all, you will need to create customer_account.xml file here in your custom module.. app/code/SK/CustomerAccountTab/view/frontend/layout/customer_account.xml Content of the File <?xml version=”1.0″?> <!– /** * * @package SKCustomerAccountTab * @author Kishan Savaliya <kishansavaliyakb@gmail.com> */ –> <page xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/Layout/etc/page_configuration.xsd”> <body> <referenceBlock name=”customer_account_navigation”> <block class=”MagentoFrameworkViewElementHtmlLinkCurrent” name=”customer-account-navigation-new-tab”> <arguments> <argument name=”path” xsi:type=”string”>sk_route/front/index</argument> <argument name=”label” xsi:type=”string”>Custom tab (SK)</argument> </arguments> </block> </referenceBlock> </body>… Continue reading How to add custom tab in Customer Account Sidebar Magento 2