Mount API Routes in Express

Update src/app.js to register the main API router.

We will expose all API endpoints under /api/v1.

Versioning helps introduce future API changes without immediately breaking existing clients.

Mount Versioned API Routes
import apiRoutes from './routes/index.js';

app.use('/api/v1', apiRoutes);

Registers all API endpoints under the /api/v1 prefix.

Key Takeaways
  • Version API endpoints using a consistent prefix.

  • Centralize route registration.

  • Separate API versions when breaking changes are introduced.