Content Beyond The Syllabus WDF
Content Beyond The Syllabus WDF
ENGINEERING COLLEGE
(An Autonomous Institution)
Approved by AICTE, New Delhi, Permanently Affiliated to Anna University- Chennai,
Accredited by National Board of Accreditation (NBA), New Delhi &
National Assessment and Accreditation Council (NAAC), Bangalore with ‘A’ Grade
PERUNDURAI -638 057, TAMILNADU, INDIA.
JAMstack Architecture
1. Introduction to JAMstack
JAMstack stands for JavaScript, APIs, and Markup. It is a modern web development
architecture that focuses on performance, scalability, security, and better developer experience.
Unlike traditional monolithic architectures, JAMstack decouples the frontend from the backend,
allowing content and services to be served directly from a Content Delivery Network (CDN).
JAMstack is not a specific technology or framework but a development philosophy that
leverages static site generation and headless CMSs to deliver fast, secure, and dynamic web
applications.
2. Core Components of JAMstack
A. JavaScript
JavaScript is used to handle dynamic functionalities on the client-side.
It runs entirely in the browser and fetches data via APIs.
Frameworks like React, Vue, Angular, or even plain JavaScript can be used.
B. APIs
All server-side operations or database actions are abstracted into reusable APIs.
These can be third-party services (e.g., Stripe, Auth0) or custom-built using serverless functions.
Examples: REST, GraphQL, or third-party cloud services.
C. Markup
Prebuilt HTML pages are generated at build time using Static Site Generators (SSGs).
Tools like Next.js, Gatsby, Hugo, Jekyll are popular.
These markup files are served from a CDN for high-speed delivery.
3. JAMstack Workflow
Developer writes content or code using a static site generator and version control (e.g., Git).
Content is pulled from a Headless CMS (like Contentful, Sanity, Strapi) via APIs.
Build tools generate static HTML based on the templates and content.
Files are deployed to a CDN, such as Netlify or Vercel.
Client-side JavaScript handles interactivity, authentication, and communication with APIs.
4. Benefits of JAMstack
A. Performance
Since content is served statically from a CDN, load times are significantly reduced.
No need to wait for server-side rendering on each request.
B. Security
No server or database to be compromised, reducing the attack surface.
APIs are isolated and secure.
C. Scalability
Easy to scale as static files can be cached globally across multiple CDN nodes.
High traffic won’t overwhelm backend servers.
D. Developer Experience
Use of Git, SSGs, and modern build tools offers a streamlined workflow.
Faster development and deployment cycles.
E. Cost Efficiency
Hosting static files is much cheaper than maintaining server infrastructure.
Serverless computing allows pay-as-you-go pricing for backend logic.
5. Comparison with Traditional Architecture
Feature JAMstack Traditional Web Stack (LAMP, MEAN, etc.)
Security More secure (no direct DB) Prone to attacks (SQLi, XSS)
Serverless Platforms: AWS Lambda Netlify Functions Azure Functions Google Cloud
Functions
8. Limitations of JAMstack
Build Time Complexity: Large sites may take time to rebuild fully.
Dynamic Content Handling: Requires more setup for real-time updates.
Complexity for Beginners: Understanding decoupled systems and API-based workflows can be
challenging.
9. JAMstack in Action – Example
Let’s say you want to create a blog.
You use Gatsby to generate the site.
Content is stored in Contentful.
Images are optimized using Cloudinary APIs.
You deploy your site on Netlify.
Site is delivered via CDN, ensuring blazing fast speed.
All interactions like comments, user logins, or payments are handled using third-party APIs or
serverless functions.
10. Future of JAMstack
JAMstack is rapidly evolving with frameworks like Next.js supporting Incremental Static
Regeneration (ISR).
More CMSs are becoming "headless", encouraging the JAMstack adoption.
Integration with AI, personalization, and analytics APIs is becoming common. Suited for the
"composable web", where websites are built from modular components and services.
Unit II Node JS
Node.js Debugging Techniques
1. Introduction to Debugging in Node.js
Debugging is the process of identifying and fixing bugs in your code. In Node.js, debugging is
critical due to asynchronous behavior, callbacks, and the event-driven architecture. Node.js
provides both built-in and external tools to simplify the debugging process.
Basic Debugging Techniques
A. Using console.log()
The simplest and most common method for debugging.Helps track values, flow of execution,
and identify where things go wrong.
console.log("Value of x:", x);
Pros:
Easy to implement.
No setup needed.
Cons:
Messy for large apps.
Not ideal for asynchronous code.
B. Using Node.js Built-in Debugger
Start Node with the inspect flag:
node inspect app.js
Common commands:
cont / c: Continue execution
next / n: Step to the next line
step / s: Step into a function
out / o: Step out of the current function
pause: Pause the execution
repl: Open an interactive REPL at the current break point
watch('variable'): Watch a variable’s value
Example:
node inspect index.js
debug> n
C. Breakpoints in Code
You can insert breakpoints manually:
debugger;
"version": "0.2.0",
"configurations": [
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/app.js"
]}
Usage:
js
Benefits:
Toggle logs without changing code.
Scopes logs for better tracking.
G. Logging with Winston or Bunyan
For better logging with levels, timestamps, etc., use a logging library like:
Winston:
npm install winston
js
CopyEdit
});
logger.info("App started");
Bunyan:
npm install bunyan
js
log.info("App running");
Then open Chrome DevTools → Profiler Tab → Capture and analyze performance.
Also, clinic.js tool (by nearForm) can be used:
npm install -g clinic
db.orders.aggregate([
{ $sort: { total: -1 } }
])
Explanation:
Filters orders with status = delivered
Groups by customerId, sums their amount
Sorts customers by total spent
Use Cases
Reporting & Analytics
Data transformation
Grouping and summarizing
Joining collections
Restructuring documents
Unit IV Express And Angular
JWT Authentication in Express:
Understanding JWT and Setup in Express
JWT:
JWT (JSON Web Token) is a secure, compact, and self-contained way to transmit information
between parties. It is widely used for authentication and authorization in web applications.
Format: header.payload.signature
JWT Structure
Part Description
});
req.user = user;
next();
});
res.send(`Welcome ${req.user.username}`);
});
Secure Practices
Tip Description
// Sign a token
// Verify a token
});
Unit V REACT
React Hooks in Depth
Introduction to React Hooks
React Hooks are functions introduced in React 16.8 that let you “hook into” React state and
lifecycle features from function components.
Hooks do not work inside classes — they let you use React features without classes.
Avoid complex class components.
Reuse stateful logic without HOCs or render props.
Separate concerns in components.
Better code readability and testing.
Basic Hooks
1. useState()
Used to add state to function components.
jsx
useEffect(() => {
console.log("Component rendered");
return () => {
// Cleanup
console.log("Cleanup function");
};
}, [dependencies]);
useEffect(() => {
inputRef.current.focus();
});
doSomething(a, b);
}, [a, b]);
useLayoutEffect(() => {
}, []);
useImperativeHandle(ref, () => ({
customMethod() {
}));
10. useDebugValue()
Used to display custom debug info in React DevTools.
jsx
useDebugValue(value);
Custom Hooks
A custom hook is a JavaScript function that uses one or more React hooks.
jsx
function useCounter(initialValue) {