mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-12-01 06:55:45 +01:00
24 lines
750 B
TypeScript
24 lines
750 B
TypeScript
// backend/src/routes/auth.ts
|
|
import express from 'express';
|
|
import {
|
|
login,
|
|
register,
|
|
logout,
|
|
getCurrentUser,
|
|
validateToken
|
|
} from '../controllers/authController.js';
|
|
import { authMiddleware } from '../middleware/auth.js';
|
|
import { validateLogin, validateRegister, handleValidationErrors } from '../middleware/validation.js';
|
|
|
|
const router = express.Router();
|
|
|
|
// Public routes
|
|
router.post('/login', validateLogin, handleValidationErrors, login);
|
|
router.post('/register', validateRegister, handleValidationErrors, register);
|
|
router.get('/validate', validateToken);
|
|
|
|
// Protected routes (require authentication)
|
|
router.post('/logout', authMiddleware, logout);
|
|
router.get('/me', authMiddleware, getCurrentUser);
|
|
|
|
export default router; |