Create the User Route

Create src/routes/user.routes.js.

Use Express Router to define the user endpoints.

For now, register the create endpoint. We will add the remaining CRUD operations in the following sections.

src/routes/user.routes.js
import { Router } from 'express';
import { createUser } from '../controllers/user.controller.js';

const router = Router();

router.post('/', createUser);

export default router;

Registers the POST /users endpoint and connects it to the createUser controller.

Key Takeaways
  • Express Router defines resource-specific endpoints.

  • POST /users creates a user.

  • Route handlers should delegate processing to controllers.