const express = require('express');
const path = require('path');

const router = express.Router();
const pub = (...p) => path.join(__dirname, '..', 'public', ...p);

// Landing (public — served before auth middleware via express.static, but also as fallback route)
router.get('/', (req, res) => res.sendFile(pub('landing.html')));

// Dashboard (protected — after auth)
router.get('/dashboard', (req, res) => res.sendFile(pub('dashboard.html')));
router.get('/home', (req, res) => res.redirect('/dashboard'));

// Tools
router.get('/md', (req, res) => res.sendFile(pub('md.html')));
router.get('/editor', (req, res) => res.sendFile(pub('editor.html')));
router.get('/sanitizer', (req, res) => res.sendFile(pub('sanitizer.html')));
router.get('/converter', (req, res) => res.sendFile(pub('converter.html')));
router.get('/formatter', (req, res) => res.sendFile(pub('formatter.html')));
router.get('/password', (req, res) => res.sendFile(pub('password.html')));
router.get('/regex', (req, res) => res.sendFile(pub('regex.html')));

module.exports = router;
