Create Authentication Routes
Update src/routes/auth.routes.js.
Register the registration and login endpoints.
Apply validation middleware before the controllers.
src/routes/auth.routes.js
import { Router } from 'express';
import { register, login } from '../controllers/auth.controller.js';
import { validateBody } from '../middleware/validate.middleware.js';
import {
registerSchema,
loginSchema
} from '../validators/auth.validator.js';
const router = Router();
router.post('/register', validateBody(registerSchema), register);
router.post('/login', validateBody(loginSchema), login);
export default router;Registers registration and login endpoints with their respective validation schemas.
Key Takeaways
Authentication endpoints belong in a separate router.
Validate registration and login payloads.
Keep authentication route definitions simple.