Ever forget to close database connections or release file handles? 🤔 TypeScript 5.2's `using` declarations solve this with automatic resource cleanup at scope exit. The problem: Manual cleanup with try/finally blocks is error-prone and verbose. The solution: `using` declarations automatically call `Symbol.dispose()` when variables go out of scope. Key benefits: → Eliminates try/finally boilerplate → Guaranteed cleanup even with exceptions → Works with both sync and async resources → Type-safe with `Disposable` interface Perfect for database connections, file handles, network sockets, or any resource needing cleanup. What's the most resource-intensive operation in your codebase that could benefit from automatic cleanup? #TypeScript #JavaScript #CleanCode #ResourceManagement #WebDevelopment
Arsalan Mughal’s Post
More Relevant Posts
-
Everyone says "JavaScript is async" — but how does it actually work under the hood? The Event Loop runs in a cycle through 4 phases: ⏰ Timer → runs setTimeout & setInterval callbacks 📥 Poll → handles I/O (file reading, network, database) ✅ Check → runs setImmediate callbacks 🚪 Close → cleanup callbacks (socket.close etc.) But here's the part most people miss 👇 Inside this big cycle, there's a smaller inner cycle that runs between EVERY phase: process.nextTick() — runs first, empties completely Promise callbacks — runs second, empties completely
To view or add a comment, sign in
-
-
Since I kept forgetting the steps to set up an Express.js project with TypeScript, I built a script to automate the entire process. Here are some of the things you can automate with Bash script: - Syncing your local branch to remote branch on Git. - Building and running automation. - Deployment scripts. - File management such as finding logs, renaming files, and backup folders. - Database Tasks such as running migration, backing up databases, and seeding data. - API and cron jobs. Small tools like this can save time, reduce mistakes, and can help you focus to bigger things. You can check the script here: https://lnkd.in/g2neMj6q #BashScript #ExpressJS #NodeJS #TypeScript #JavaScript #Automation #DevTools #BackendDevelopment
To view or add a comment, sign in
-
-
Why can't config files have comments? If you've ever pasted a JSON config and immediately wished you could explain what a block of settings actually does — JSON5 is worth knowing about. JSON5 is a superset of JSON that adds a few things that make configuration files much more pleasant to work with: 💬 Comments — both inline and block ✅ Trailing commas — no more hunting down which line is missing one 🔓 Unquoted property names — copy directly from TypeScript/JavaScript without reformatting 📝 Multi-line strings Valid JSON is always valid JSON5, so there's no migration pain. It works across the stack too — npm package for JS/TS, json5k library for Kotlin, and IntelliJ supports it out of the box. I wrote up a quick intro with examples — including a real-world Renovate config — here 👇 https://lnkd.in/grFnkvRd #JSON5 #WebDev #JavaScript #TypeScript #Kotlin #DevTools #SoftwareDevelopment
To view or add a comment, sign in
-
🚀 30 Days of JavaScript – Day 21 Today I explored how applications communicate with servers. 💡 Project: Fetching Data from API This project loads user data from an external API and displays it dynamically. 🧠 Concepts Used: i) fetch API ii) async/await iii) JSON data handling iv) DOM rendering 📌 This helped me understand how frontend applications interact with backend services. 🎥 Demo below 👇 Full source code in the First comments. #JavaScript #WebDevelopment #API #FrontendDevelopment #LearningJavaScript
To view or add a comment, sign in
-
Today’s session from Suraj sir was on Node.js file system (fs module). We went through how Node interacts with the file system — creating, reading, updating and deleting files, and also working with directories. Covered methods like writeFileSync, readFileSync, appendFileSync, mkdirSync, renameSync, unlinkSync and more. Everything was explained step by step, line by line, which made it easier to follow. Started applying the concepts by working on the ER diagram and related models, connecting how data and files are handled in real scenarios. It also made me realize that understanding concepts in class is different from applying them on your own. Focusing on consistent practice and revision to get more comfortable. #Nodejs #Backend #LearningInPublic #JavaScript #DBMS #ChaiaurCode #Surajkumarjha sir
To view or add a comment, sign in
-
-
#Day24 JavaScript is starting to feel less like writing code… and more like preparing code for the real world. Today I learned about environment variables and why not everything belongs inside your code. Three things for today: => Security Sensitive data (API keys, database URLs) stays out of your codebase. => Flexibility The same code can run in different environments without changes. => Clean structure Your code focuses on logic, not configuration. I stopped asking, where do I store this value? and started asking, should this value even be inside my code? Because writing code is one thing, but preparing it for real-world use is another. Same language. More responsibility. #JavaScript #NodeJS #BackendDevelopment #WebDevelopment #LearningToCode #M4ACELearningChallenge
To view or add a comment, sign in
-
-
Here’s a clean breakdown of how a request travels through a NestJS application: 👉 1. Middleware Handles logging, request parsing, and pre-processing before anything else. 👉 2. Guards Acts as a gatekeeper 🔐 — checks authentication & authorization (e.g., JWT validation). 👉 3. Pipes Validates and transforms incoming data (e.g., DTO validation, type conversion). 👉 4. Controller Receives the request and decides which logic to execute. 👉 5. Service (Business Logic) This is where the real work happens — database queries, API calls, etc. 👉 6. Interceptors Wrap around the response — useful for logging, formatting responses, or caching. 👉 7. Exception Filters Catch and handle errors globally to ensure clean and consistent API responses. ✅ Flow Summary: Middleware → Guards → Pipes → Controller → Service → Interceptors → Exception Filters → Response 💡 Why this matters? This layered architecture makes applications: ✔ Scalable ✔ Maintainable ✔ Testable #NestJS #NodeJS #BackendDevelopment #SoftwareEngineering #WebDevelopment #API #FullStackDeveloper #TechInterview #Coding #JavaScript #TypeScript #SystemDesign #Developers #Programming
To view or add a comment, sign in
-
-
Ever wonder what's actually happening under the hood when Promise.all executes your parallel API calls? Here's the magic: libuv. Node.js doesn't run requests in parallel on a single thread. Instead: 1. Thread Pool — libuv queues your requests to worker threads (default 4). 2. OS Multiplexing — epoll/kqueue monitors network sockets simultaneously. 3. Event Loop — The main thread stays responsive, orchestrating callbacks. When you fire 3 API calls with Promise.all, libuv: - Registers them with the OS. - Worker threads handle DNS/I/O in parallel. - The event loop waits for responses (non-blocking). - Callbacks fire when data arrives. The result? True concurrency without blocking the main thread. This is why JavaScript can handle thousands of concurrent connections despite being single-threaded. Understanding libuv is key to understanding modern Node.js. #NodeJS #JavaScript #SystemArchitecture #Backend
To view or add a comment, sign in
-
I just shipped my first npm package. 🚀 glowlog — a zero-dependency logger that replaces 6 packages with 1. The problem: Every Node.js project I built needed Winston + pino-pretty + morgan + daily-rotate-file + redaction + correlation IDs. That's 6 installs for one feature. So I fixed it. glowlog gives you: ✅ Beautiful box-style colored terminal logs ✅ Auto file:line detection on every log ✅ Auto-redaction (passwords, tokens, API keys) ✅ Request ID threading — no setup needed ✅ File rotation built-in ✅ HTTP middleware for Express / NestJS ✅ Browser support — same import, CSS-styled console ✅ Zero dependencies One install: npm install glowlog This is v1 — it works, but it can be better. Bugs, issues, ideas, PRs — all welcome. That's the whole point of open source. Link in comments 👇 #nodejs #npm #opensource #javascript #developer #nestjs
To view or add a comment, sign in
-
Honestly, Pushing your code publicly feels vulnerable. What if someone judges it? What if it's not perfect? What if........ Then I remembered, perfect code that nobody sees helps nobody. So here it is: Public. Real. Work in progress. https://lnkd.in/d7Z_V8hm What's inside right now: 4 cleanly separated layers Domain that doesn't know the database exists Business logic that doesn't know ASP.NET exists JWT authentication built from scratch Repository Pattern + Unit of Work EF Core with proper entity relationships Global exception handling middleware MVC login and register views Every folder. Every file. Every decision made intentionally. Not because I had to. Because I want to be the kind of developer who can walk into any interview and explain exactly why the code is structured the way it is. Building PayRound in public. follow along. 💪 🔗 https://lnkd.in/d7Z_V8hm #BuildingInPublic #DotNet #ASPNetCore #CleanArchitecture #Nigeria #SoftwareDevelopment #GitHub
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development