<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: SHAHNAWAZ SAZID</title>
    <description>The latest articles on DEV Community by SHAHNAWAZ SAZID (@sazid60).</description>
    <link>https://dev.to/sazid60</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1252639%2F65279db4-5dd3-48eb-a802-b485c04dd11d.jpeg</url>
      <title>DEV Community: SHAHNAWAZ SAZID</title>
      <link>https://dev.to/sazid60</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sazid60"/>
    <language>en</language>
    <item>
      <title>𝐎𝐛𝐣𝐞𝐜𝐭-𝐎𝐫𝐢𝐞𝐧𝐭𝐞𝐝 𝐏𝐫𝐨𝐠𝐫𝐚𝐦𝐦𝐢𝐧𝐠 𝐖𝐢𝐭𝐡 𝐓𝐲𝐩𝐞𝐬𝐜𝐫𝐢𝐩𝐭 : 𝐚𝐤𝐚 “𝐍𝐨 𝐦𝐨𝐫𝐞 𝐦𝐞𝐬𝐬𝐲 𝐜𝐨𝐝𝐞, 𝐨𝐧𝐥𝐲 𝐜𝐥𝐚𝐬𝐬𝐲 𝐯𝐢𝐛𝐞𝐬”</title>
      <dc:creator>SHAHNAWAZ SAZID</dc:creator>
      <pubDate>Wed, 07 May 2025 10:39:54 +0000</pubDate>
      <link>https://dev.to/sazid60/--46lp</link>
      <guid>https://dev.to/sazid60/--46lp</guid>
      <description>&lt;p&gt;I finally sat down and decided it was time to face my fears and tackle Object-Oriented Programming (OOP) in TypeScript. And guess what? It’s not just buzzwords and confusing diagrams it actually makes sense&lt;/p&gt;

&lt;p&gt;Checkout All Detailed OOP With Ts Concepts and Code In My GitHub Readme : &lt;a href="https://lnkd.in/gG_9UEH9" rel="noopener noreferrer"&gt;https://lnkd.in/gG_9UEH9&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s a breakdown of what I’ve been learning with a sprinkle of chaos, caffeine, and curiosity:&lt;/p&gt;

&lt;p&gt;𝑪𝒍𝒂𝒔𝒔 &amp;amp; 𝑶𝒃𝒋𝒆𝒄𝒕&lt;/p&gt;

&lt;p&gt;Think of a class like your mom’s biryani recipe and the object is the biryani you make from it. The recipe doesn't change, but you can make as many plates as you want .&lt;/p&gt;

&lt;p&gt;𝑰𝒏𝒉𝒆𝒓𝒊𝒕𝒂𝒏𝒄𝒆&lt;/p&gt;

&lt;p&gt;Why write the same code twice when you can inherit your dad’s methods and your mom’s properties? OOP lets one class borrow another’s stuff. Just like real life but with less drama.&lt;/p&gt;

&lt;p&gt;𝑻𝒚𝒑𝒆 𝑮𝒖𝒂𝒓𝒅𝒔 (𝒕𝒚𝒑𝒆𝒐𝒇 &amp;amp; 𝒊𝒏)&lt;/p&gt;

&lt;p&gt;These are the bouncers of TypeScript. They check IDs at the door before letting values in. “Sorry buddy, only strings allowed here.”&lt;/p&gt;

&lt;p&gt;𝘪𝘯𝘴𝘵𝘢𝘯𝘤𝘦𝘰𝘧 :&lt;br&gt;
This one checks if an object is from a certain class. Great for those moments when you’re like, “Wait... what even are you?”&lt;/p&gt;

&lt;p&gt;𝑨𝒄𝒄𝒆𝒔𝒔 𝑴𝒐𝒅𝒊𝒇𝒊𝒆𝒓𝒔&lt;/p&gt;

&lt;p&gt;public, private, and protected the introvert/extrovert settings for your class properties. Finally, I can keep my variables from oversharing.&lt;/p&gt;

&lt;p&gt;𝑮𝒆𝒕𝒕𝒆𝒓𝒔 &amp;amp; 𝑺𝒆𝒕𝒕𝒆𝒓𝒔&lt;/p&gt;

&lt;p&gt;Why give direct access to your private stuff when you can negotiate with a getter? These let you control how your properties are viewed and changed like a velvet rope to your data.&lt;/p&gt;

&lt;p&gt;𝑺𝒕𝒂𝒕𝒊𝒄 𝑴𝒆𝒕𝒉𝒐𝒅𝒔 &amp;amp; 𝑷𝒓𝒐𝒑𝒆𝒓𝒕𝒊𝒆𝒔&lt;/p&gt;

&lt;p&gt;These belong to the class, not any specific object. It's like that one cousin who thinks they speak for the whole family.&lt;/p&gt;

&lt;p&gt;𝑷𝒐𝒍𝒚𝒎𝒐𝒓𝒑𝒉𝒊𝒔𝒎&lt;/p&gt;

&lt;p&gt;Different objects acting the same way. Like how every intern, no matter the department, somehow ends up making coffee.&lt;/p&gt;

&lt;p&gt;𝑨𝒃𝒔𝒕𝒓𝒂𝒄𝒕𝒊𝒐𝒏&lt;/p&gt;

&lt;p&gt;Hide the messy details and just show the clean interface. It’s like every cooking show ever: “And wooooh! I already made this off-camera!”&lt;/p&gt;

&lt;p&gt;𝑬𝒏𝒄𝒂𝒑𝒔𝒖𝒍𝒂𝒕𝒊𝒐𝒏&lt;br&gt;
Keep your internal logic locked up like it’s your browser history. Only show what’s necessary. Boundaries matter even in code.&lt;/p&gt;

&lt;h1&gt;
  
  
  TypeScript #OOP #ObjectOrientedProgramming
&lt;/h1&gt;

</description>
    </item>
    <item>
      <title>Setting Up a TypeScript + Express + MongoDB(Mongoose) Backend from Scratch</title>
      <dc:creator>SHAHNAWAZ SAZID</dc:creator>
      <pubDate>Mon, 07 Apr 2025 05:27:19 +0000</pubDate>
      <link>https://dev.to/sazid60/setting-up-a-typescript-express-mongodbmongoose-backend-from-scratch-3273</link>
      <guid>https://dev.to/sazid60/setting-up-a-typescript-express-mongodbmongoose-backend-from-scratch-3273</guid>
      <description>&lt;p&gt;If you're planning to build a scalable, type-safe Node.js backend, integrating Express, Mongoose, TypeScript, dotenv, and CORS, here's a clean and efficient way to set it up. We'll also configure a .env file and write some essential build scripts. Let's walk through the setup step by step!&lt;/p&gt;

&lt;p&gt;🧱 1. Initialize the Project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a package.json file with default settings.&lt;/p&gt;

&lt;p&gt;⚙️ 2. Install Core Dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install express mongoose dotenv cors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are the libraries we'll need for our application:&lt;/p&gt;

&lt;p&gt;express: Minimal and flexible Node.js web framework.&lt;/p&gt;

&lt;p&gt;mongoose: ODM for MongoDB.&lt;/p&gt;

&lt;p&gt;dotenv: Loads environment variables from .env.&lt;/p&gt;

&lt;p&gt;cors: Enables Cross-Origin Resource Sharing.&lt;/p&gt;

&lt;p&gt;🛠️ 3. Install Dev Dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev typescript @types/node @types/express @types/cors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These packages are required for TypeScript support and type definitions:&lt;/p&gt;

&lt;p&gt;typescript: The TS compiler.&lt;/p&gt;

&lt;p&gt;@types/node, @types/express, @types/cors: Type declarations for Node.js, Express, and CORS.&lt;/p&gt;

&lt;p&gt;📁 4. Initialize TypeScript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tsc --init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the generated tsconfig.json, update the following two lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"rootDir": "./src",
"outDir": "./dist",

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures TypeScript will transpile source files from src/ to dist/.&lt;/p&gt;

&lt;p&gt;🧪 5. Add Scripts to package.json&lt;br&gt;
Inside your package.json, update the scripts section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "build": "tsc",
  "start": "node ./dist/app.js",
  "dev": "ts-node-dev --respawn src/app.ts"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The build command compiles TypeScript, and start runs the built JavaScript. If you’re using ts-node-dev for development, you can hot-reload using the dev script.&lt;/p&gt;

&lt;p&gt;🔥 Install ts-node-dev if using the dev command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev ts-node-dev

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🌐 6. Create the .env File&lt;br&gt;
At the root of the project, create a .env file and add your environment variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PORT=5000
DATABASE_URL=mongodb URI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📝 Note: Replace sensitive credentials before committing. Add .env to .gitignore!&lt;/p&gt;

&lt;p&gt;🧠 7. Basic Project Structure&lt;br&gt;
Create your folder structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;project-root/
│
├── src/
│   ├── app.ts
│   └── server.ts
│
├── dist/
├── .env
├── tsconfig.json
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💻 8. Sample server.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/server.ts
import express from 'express';
import mongoose from 'mongoose';
import dotenv from 'dotenv';
import cors from 'cors';

dotenv.config();

const app = express();
const PORT = process.env.PORT || 5000;

// Middleware
app.use(cors());
app.use(express.json());

// MongoDB Connection
mongoose
  .connect(process.env.DATABASE_URL as string)
  .then(() =&amp;gt; console.log("MongoDB connected"))
  .catch((err) =&amp;gt; console.error("MongoDB connection error:", err));

// Routes
app.get('/', (_req, res) =&amp;gt; {
  res.send('API is running...');
});

app.listen(PORT, () =&amp;gt; {
  console.log(`Server is running on port ${PORT}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧪 9. Build and Run the Project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your server should now be live and connected to your MongoDB Atlas cluster!&lt;/p&gt;

&lt;p&gt;🧼 Bonus Tips&lt;br&gt;
Use ts-node-dev during development for hot reloading:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Always include .env in your .gitignore.&lt;/p&gt;

&lt;p&gt;Use proper error handling middleware and structure routes/controllers separately for larger apps.&lt;/p&gt;

&lt;p&gt;📌 Conclusion&lt;br&gt;
You’ve now built a clean TypeScript backend setup using Express, Mongoose, dotenv, and CORS. This is a solid boilerplate for most backend projects — scalable, type-safe, and easy to maintain.&lt;/p&gt;

&lt;p&gt;If you found this helpful, feel free to share it with your dev circle! 💙&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>mongodb</category>
      <category>mongoose</category>
      <category>express</category>
    </item>
  </channel>
</rss>
