FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

Β© 2026 FlareStart. All rights reserved.

Back to articles
πŸ— Designing Public & Admin Routes Properly in Express (Node.js + TypeScript)
How-ToWeb Development

πŸ— Designing Public & Admin Routes Properly in Express (Node.js + TypeScript)

via Dev.to WebdevKarthick1mo ago

When building a scalable backend API, one common question is: Should we separate admin routes like /api/admin/categories Or protect routes using middleware? In this article, I’ll show you the clean and scalable way to structure public and admin routes. πŸš€ The Use Case We are building a Blog System with categories. We need: Public users β†’ View all categories Admin users β†’ Create categories ❌ Bad Practice (URL-Based Role Separation) POST /api/admin/categories GET /api/categories Why this is not ideal? URL becomes tightly coupled with roles Harder to scale Not RESTful Role logic leaks into routing βœ… Recommended Approach (Middleware-Based Authorization) Keep URLs clean and RESTful. GET /api/categories β†’ Public POST /api/categories β†’ Admin only Access control should be handled by middleware, not the URL. πŸ“‚ Project Structure (Feature-Based Architecture) src/ β”œβ”€β”€ modules/ β”‚ β”œβ”€β”€ categories/ β”‚ β”‚ β”œβ”€β”€ categories.controller.ts β”‚ β”‚ β”œβ”€β”€ categories.service.ts β”‚ β”‚ β”œβ”€β”€ categories.routes.ts β”‚ β”‚ β”œβ”€β”€ categ

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
21 views

Related Articles

150 million users later, Roblox competitor Rec Room is shutting down
How-To

150 million users later, Roblox competitor Rec Room is shutting down

The Verge β€’ 1d ago

Here are our favorite spring cleaning deals from Amazon’s Big Spring Sale
How-To

Here are our favorite spring cleaning deals from Amazon’s Big Spring Sale

The Verge β€’ 1d ago

What we’re looking for in Startup Battlefield 2026 and how to put your best application forward
How-To

What we’re looking for in Startup Battlefield 2026 and how to put your best application forward

TechCrunch β€’ 1d ago

Build Days That Actually Mean Something
How-To

Build Days That Actually Mean Something

Medium Programming β€’ 1d ago

I have blogged about the difference between code coverage and test coverage and why it matters to distinguish between these 2.
How-To

I have blogged about the difference between code coverage and test coverage and why it matters to distinguish between these 2.

Dev.to Beginners β€’ 1d ago

Discover More Articles