Day 2 - Yesterday Spring Boot. Today Node.js. Same API, different language — spot the patterns. 🚀TechFromZero Series - NodejsFromZero This isn't a Hello World. It's a real layered architecture: 📐 Request → Route → Controller → Service → Model → MySQL 🔗 The full code (with step-by-step commits you can follow): https://lnkd.in/dBXFMDT2 If anyone has a idea, improvement or recommendation please try to fork the repo and submit a pull request, Everyone is welcome to do so. 🧱 What I built (step by step): 1️⃣ Express server with health check 2️⃣ MySQL connection pool with auto-init 3️⃣ Product model with raw SQL queries 4️⃣ DTO with toDto/toEntity mapping 5️⃣ Service layer with business logic 6️⃣ Controller with HTTP request handling 7️⃣ Express Router wiring endpoints 8️⃣ Error handling + seed data 💡 Every file has detailed comments explaining WHY, not just what. Written for any beginner who wants to learn Node.js + Express by reading real code — with full clarity on each step. 👉 If you're a beginner learning Node.js, clone it and read the commits one by one. Each commit = one concept. Each file = one lesson. Built from scratch, so nothing is hidden. 🔥 This is Day 2 of a 50-day series. A new technology every day. Follow along! 🌐 See all days: https://lnkd.in/dhDN6Z3F #TechFromZero #Day2 #NodeJS #Express #JavaScript #REST #API #LearnByDoing #OpenSource #BeginnerGuide #100DaysOfCode #CodingFromScratch
Node.js API Architecture with Express and MySQL
More Relevant Posts
-
Leaving Node.js behind: Building a raw HTTP server in Go. After spending the week locking down my PostgreSQL database, it is finally time to build the API server. But moving from Node.js to Go requires a complete mental reset. In Node, you reach for Express.js immediately. You write app.get("/", (req, res) => {}) and you're good to go. In Go? There is no Express by default. You build it raw using the standard library (net/http). This simple block of code completely flips the script on how you handle data. package main import ( "log" "net/http" ) // The mental shift happens HERE: (w, r) func handler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("hello world")) } func main() { http.HandleFunc("/", handler) if err := http.ListenAndServe(":8080", nil); err != nil { log.Fatal(err) } } In Node, it’s always (req, res) - Request first, Response second. In Go, the handler looks like this: (w http.ResponseWriter, r *http.Request). Response first, Request second. Why? Because Go treats the ResponseWriter (w) as a literal tool you are handed to execute your job. The server effectively says: "Here is your pen (w). Now look at the paperwork (r) and write your response back immediately." I'm officially writing my first route to start the Auth sequence. It’s raw, it’s fast, and there’s no framework magic hiding the fundamentals from me. We move! 💪🏾 To the devs who made the switch from JavaScript/Node.js to Go: What was the hardest habit you had to break? Let’s gist in the comments 👇🏾 #Golang #NodeJS #BackendEngineering #API #SoftwareDevelopment #TechBro #TechInNigeria #WeMove
To view or add a comment, sign in
-
-
While working on a TypeScript backend, I had to decide: ORM or Query Builder? I ended up choosing Kysely — and it changed how I think about database access. Here’s why: • Full type safety with raw SQL-like control • No hidden abstractions (you know exactly what query is running) • Easier to debug compared to heavy ORMs • Flexible enough for complex queries ORMs are great for speed in the beginning. But as complexity grows, abstraction can sometimes become a limitation. Kysely gave the best of both worlds: -> Type safety + control. Lesson: The right tool depends on how much control your system needs #BackendDevelopment #TypeScript #Nodejs #SoftwareEngineering #DatabaseDesign #SystemDesign #WebDevelopment #CleanCode #ScalableSystems #DevelopersLife
To view or add a comment, sign in
-
Node.js vs. Go HTTP Server 🌐 Leaving Node.js behind: Building a raw HTTP server in Go 🚀💻 After spending the week locking down my PostgreSQL database, it is finally time to build the API server. But moving from Node.js to Go requires a complete mental reset. In Node, you reach for Express.js immediately. You write app.get("/", (req, res) => {}) and you're good to go. In Go? There is no Express. You build it raw using the standard library (net/http). And Go completely flips the script on how you handle data. In Node, it’s always (req, res) — Request first, Response second. In Go, the handler looks like this: func handler(w http.ResponseWriter, r *http.Request) Response first, Request second. Why? Because Go treats the ResponseWriter as a literal tool you are handed to execute your job. The server says: "Here is your pen (w). Now look at the paperwork (r) and write your response back immediately." I'm officially writing my first route to start the Auth sequence (Signup/Login). It’s raw, it’s fast, and there’s no framework magic hiding the fundamentals from me. We move! 💪🏾 To my devs who made the switch from JavaScript/Node.js to Go: What was the hardest habit you had to break? Let’s gist in the comments 👇🏾 #Golang #NodeJS #BackendEngineering #API #SoftwareDevelopment #TechBro #TechInNigeria #WeMove
To view or add a comment, sign in
-
-
The best way to learn a new backend language? Build something you are familiar with. Since I was laid off, I've been keeping busy. I built ChopChop, a URL shortener implemented identically in 8 backend stacks: 🐘 PHP / Symfony 🐍 Python / FastAPI 🟦 TypeScript / Express 💧 Elixir / Phoenix ☕ Java / Spring Boot 🐹 Go / net/http 💎 Ruby / Sinatra 🔷 C# / ASP.NET Core Same four API endpoints, same PostgreSQL database, one shared test suite that every implementation has to pass. I built the whole thing with Claude Code. I started with PHP/Symfony since that's what I know best, and once I had the API design and test suite ironed out, the rest moved fast. I could point Claude Code at the spec and the tests, then focus on understanding what it generated rather than fighting boilerplate. Eight backends in a couple of days. The repo is open source. Add a language, study an implementation, or just poke around. 👉 https://lnkd.in/gu-Zk2kD What language would you add next?
To view or add a comment, sign in
-
"Does the following code look malicious?" We asked an LLM that. The answer was useless. We tested AI generated code with tools like Claude and Codex across 7 frameworks: Flask, Django, Rails, SpringBoot, ExpressJS, .NET, and Laravel. It got the obvious right: SQL injection, parameterized queries, ORMs. But it dropped context-specific protections: CSRF tokens missing on POST forms, unscoped queries creating IDORs, hardcoded fallback secrets shipping to production. Telling it to “write secure code” or to review its own output didn’t fix it. Longer prompts actually made it worse. ✅ Here’s what improved the results: >> Be explicit, not generic Define what “secure” looks like in your stack. Use examples. >> Use framework-specific references Show exactly how CSRF, secrets, and redirects are implemented; don’t just say that they matter. >> Keep prompts tight More context didn’t help. Focused inputs performed better. >> Treat it as iterative Fix one class of issues, rerun, refine. New gaps will appear. >> Validate downstream SAST and manual review still catch what generation misses. Full breakdown in the carousel. 👇
To view or add a comment, sign in
-
You'll want to see these practical tips to help you prompt the most secure AI generated code. 👇 Read the full post at https://lnkd.in/gQZK7DHP
"Does the following code look malicious?" We asked an LLM that. The answer was useless. We tested AI generated code with tools like Claude and Codex across 7 frameworks: Flask, Django, Rails, SpringBoot, ExpressJS, .NET, and Laravel. It got the obvious right: SQL injection, parameterized queries, ORMs. But it dropped context-specific protections: CSRF tokens missing on POST forms, unscoped queries creating IDORs, hardcoded fallback secrets shipping to production. Telling it to “write secure code” or to review its own output didn’t fix it. Longer prompts actually made it worse. ✅ Here’s what improved the results: >> Be explicit, not generic Define what “secure” looks like in your stack. Use examples. >> Use framework-specific references Show exactly how CSRF, secrets, and redirects are implemented; don’t just say that they matter. >> Keep prompts tight More context didn’t help. Focused inputs performed better. >> Treat it as iterative Fix one class of issues, rerun, refine. New gaps will appear. >> Validate downstream SAST and manual review still catch what generation misses. Full breakdown in the carousel. 👇
To view or add a comment, sign in
-
🔍 Learning Winston Logging in Node.js: From Development to Production Recently, I explored the Winston library in Node.js, and it gave me a strong understanding of how professional backend applications handle logging beyond console.log(). In real-world development, logging is not just about printing messages. It is about tracking application flow, debugging issues, monitoring APIs, and maintaining production stability. 💻 In Development Environment I use Winston to: 1.log API request flow 2.debug incoming request data 3.trace controller and service execution 4.identify validation and database issues 5.monitor authentication flow such as JWT login and registration Example logs: info → server started, API called debug → request body, token payload warn → invalid credentials, suspicious attempts error → database and server exceptions 🏭 In Production Environment Winston becomes even more powerful: 1.store logs in files 2.separate error logs and combined logs add timestamps 3. keep JSON formatted logs 4. monitor system failures 5. track audit activities such as admin actions and CRUD operations 6. This helps teams quickly debug issues in live applications and improve reliability. ✨ One key lesson: Development logs help build confidence. Production logs help build trust. Logging is one of the most important practices in backend development, especially while working with Node.js, TypeScript, Express, JWT, and MySQL applications. #NodeJS #JavaScript #TypeScript #BackendDevelopment #Winston #Logging #ExpressJS #WebDevelopment #SoftwareEngineering #FullStackDeveloper #LearningInPublic
To view or add a comment, sign in
-
Hot take: I've seen engineers spend 2 hours configuring a Docker Compose file just to test a 10-line function. You don't need a full Postgres instance to test a user service. You don't need a Redis container to test a cache layer. You need fast, isolated, reliable tests. That's why I open-sourced @backend-master/test-utils. package- https://lnkd.in/guWmyCRe github- https://lnkd.in/gtx9GYPR Here's what it solves: ❌ Before: Spinning up databases just to test a findOne query ✅ After: MockDatabase with full CRUD in 3 lines of code ❌ Before: Manually building mock HTTP response objects ✅ After: HttpTestBuilder.ok({ userId: 1 }) — done ❌ Before: Hardcoded test data that breaks randomly ✅ After: Fixtures.user(), Fixtures.products(10) — realistic every time ❌ Before: let wasCalled = false; someService.fn = () => { wasCalled = true; } ✅ After: Spy.create() — call count, args, errors, all built-in Built with TypeScript. Zero runtime dependencies. MIT licensed. I'd love feedback from backend engineers — what testing pain point should I tackle next? What should I build next? Drop a comment 👇 → PostgreSQL adapter → GraphQL test utilities → Stream mocking → Event emitter mocks #TypeScript #BackendEngineering #SoftwareTesting #NodeJS #OpenSource #NPM #JavaScript
To view or add a comment, sign in
-
-
I would like to share my experience of Nodejs and FastAPI. I spent years building REST APIs with Node.js and Express across enterprise projects. When I switched to Python + FastAPI, here is what genuinely surprised me: 1. Zero config API documentation: With Express, I had to manually write Swagger. FastAPI generates Swagger UI and ReDoc automatically from your code. That alone saves hours. 2. Built-in data validation: In Express I used Joi or Zod. In FastAPI, Pydantic handles it natively - cleaner, faster, and tightly coupled to your models. 3. Type safety without the setup: TypeScript in Node.js requires configuration. FastAPI uses Python type hints out of the box - same safety, zero overhead. 4. Async is first-class: Both support async, but FastAPI's async feels more natural and consistent across the entire framework - no callback confusion. 5. Data heavy workloads are effortless: Integrating Pandas, NumPy, and SQLAlchemy into FastAPI endpoints is seamless - something that always felt clunky in Express. Both are great tools. But for banking systems, healthcare APIs, and data-heavy microservices - FastAPI has become my first choice. Still love you, Node.js. What is your preferred stack for building REST APIs? Drop it below! #FastAPI #Python #NodeJS #ExpressJS #BackendDevelopment #RESTAPIs #Microservices #SoftwareEngineering
To view or add a comment, sign in
-
🛑 The "undefined" Error That Broke My Brain (And How Go Actually Compiles) 🤯 Today, I decided to clean up my Go backend. My main.go file was getting too long, so I did what any Node.js developer would do: I split my database logic into a new file called user.repository.go. They were in the exact same folder. They both had package main at the top. I opened my terminal and typed what I always type: go run main.go Boom. Error: .\main.go:95:9: undefined: CreateUser Wait, what? The function is right there in the other file! Why can't main.go see it? Did I forget an import statement? Here is the massive paradigm shift I had to learn today: Go compiles by package, not by file. 🧠 The Mental Reset In Node.js, node index.js works because Node reads your entry file and automatically pulls in every other file you imported. But Go tooling is different. When you type go run main.go, you are explicitly telling the Go compiler: "Only look at this single file. Ignore everything else in the folder." Because my CreateUser function was in user.repository.go, Go never even saw it. ✅ The Production Fix The fix isn't to link the files manually. The fix is to change how you tell Go to run. Instead of go run main.go, you write: 👉 go run . This tells Go: "Run the whole module in this directory." Because both files declare package main, the compiler treats them as one single unit. All files in the same package are automatically connected. No imports needed. Stop thinking in "files". Start thinking in "packages". The backend is getting cleaner, and the fundamentals are locking in. We move! 💪🏾 I’ll leave you guys with this question: I currently have both files set to package main. What do you think happens if I change user.repository.go to say package repository instead? Let’s gist in the comments 👇🏾 #Golang #NodeJS #BackendEngineering #SoftwareArchitecture #SystemDesign #TechBro #TechInNigeria #WeMove
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