chnages
chnages
This commit is contained in:
1 parent
3e22355510
commit
e22a8dc248
71 files changed
+24775
-1
No files matched your search
@@ -0,0 +1,27 @@
|
||||
// ============================================================
|
||||
// adminRoutes.js — Admin-only API routes
|
||||
// Every route requires: logged in (JWT + active session) + admin.
|
||||
// Sole purpose: review Contact Us inquiries.
|
||||
// ============================================================
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { authenticate, requireAdmin } = require('../middleware/authMiddleware');
|
||||
const {
|
||||
getStats,
|
||||
getInquiries,
|
||||
getInquiry,
|
||||
setInquiryRead,
|
||||
deleteInquiry,
|
||||
} = require('../controllers/adminController');
|
||||
|
||||
// Apply auth + admin guard to every route in this file.
|
||||
router.use(authenticate, requireAdmin);
|
||||
|
||||
router.get('/stats', getStats);
|
||||
router.get('/inquiries', getInquiries);
|
||||
router.get('/inquiries/:id', getInquiry);
|
||||
router.patch('/inquiries/:id/read', setInquiryRead);
|
||||
router.delete('/inquiries/:id', deleteInquiry);
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,76 @@
|
||||
// ============================================================
|
||||
// authRoutes.js — All authentication API routes
|
||||
// ============================================================
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const {
|
||||
login,
|
||||
requestOTP,
|
||||
verifyOTP,
|
||||
refreshToken,
|
||||
changePassword,
|
||||
forgotPassword,
|
||||
resetPassword,
|
||||
requestChangePasswordLink,
|
||||
verifyChangePasswordLink,
|
||||
logout,
|
||||
logoutAll,
|
||||
getSessions,
|
||||
getMe,
|
||||
} = require('../controllers/authController');
|
||||
|
||||
const { authenticate } = require('../middleware/authMiddleware');
|
||||
|
||||
const {
|
||||
handleValidationErrors,
|
||||
loginRules,
|
||||
verifyOtpRules,
|
||||
requestOtpRules,
|
||||
changePasswordRules,
|
||||
forgotPasswordRules,
|
||||
resetPasswordRules,
|
||||
verifyChangePwdLinkRules,
|
||||
} = require('../middleware/validate');
|
||||
|
||||
// POST /api/auth/login — Check email + password, send OTP
|
||||
router.post('/login', loginRules, handleValidationErrors, login);
|
||||
|
||||
// POST /api/auth/request-otp — Resend OTP to user (for "resend" button)
|
||||
router.post('/request-otp', requestOtpRules, handleValidationErrors, requestOTP);
|
||||
|
||||
// POST /api/auth/verify-otp — Submit OTP to complete login
|
||||
router.post('/verify-otp', verifyOtpRules, handleValidationErrors, verifyOTP);
|
||||
|
||||
// POST /api/auth/refresh-token — Get a new access token using refresh token
|
||||
router.post('/refresh-token', refreshToken);
|
||||
|
||||
// POST /api/auth/change-password — Change password (must be logged in)
|
||||
router.post('/change-password', authenticate, changePasswordRules, handleValidationErrors, changePassword);
|
||||
|
||||
// POST /api/auth/request-change-password-link — Send email link
|
||||
router.post('/request-change-password-link', authenticate, requestChangePasswordLink);
|
||||
|
||||
// POST /api/auth/verify-change-password-link — Set new password from link
|
||||
router.post('/verify-change-password-link', verifyChangePwdLinkRules, handleValidationErrors, verifyChangePasswordLink);
|
||||
|
||||
// POST /api/auth/forgot-password — Send OTP to email for password reset
|
||||
router.post('/forgot-password', forgotPasswordRules, handleValidationErrors, forgotPassword);
|
||||
|
||||
// POST /api/auth/reset-password — Verify OTP and set new password
|
||||
router.post('/reset-password', resetPasswordRules, handleValidationErrors, resetPassword);
|
||||
|
||||
// GET /api/auth/sessions — List all active sessions for this user
|
||||
router.get('/sessions', authenticate, getSessions);
|
||||
|
||||
// POST /api/auth/logout — Logout this device only
|
||||
router.post('/logout', authenticate, logout);
|
||||
|
||||
// POST /api/auth/logout-all — Logout ALL devices
|
||||
router.post('/logout-all', authenticate, logoutAll);
|
||||
|
||||
// GET /api/auth/me — Get current user info (must be logged in)
|
||||
router.get('/me', authenticate, getMe);
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,39 @@
|
||||
// ============================================================
|
||||
// publicRoutes.js — Public website API (no authentication)
|
||||
// ============================================================
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const { submitInquiry } = require('../controllers/contactController');
|
||||
const { chat } = require('../controllers/chatController');
|
||||
const {
|
||||
getSolutions,
|
||||
getCaseStudies,
|
||||
getFeedback,
|
||||
getArticles,
|
||||
getArticleBySlug,
|
||||
getEvents,
|
||||
getGallery,
|
||||
} = require('../controllers/publicContentController');
|
||||
|
||||
const { handleValidationErrors, contactRules } = require('../middleware/validate');
|
||||
|
||||
// ---- Contact Us form -------------------------------------
|
||||
// POST /api/contact — submit a customer inquiry (7 CSE fields, Turnstile-protected)
|
||||
router.post('/contact', contactRules, handleValidationErrors, submitInquiry);
|
||||
|
||||
// ---- AI assistant chat proxy (Google Gemini) -------------
|
||||
// POST /api/chat — forwards to Gemini server-side; key never leaves the backend
|
||||
router.post('/chat', chat);
|
||||
|
||||
// ---- Public content (read-only) --------------------------
|
||||
router.get('/content/solutions', getSolutions);
|
||||
router.get('/content/case-studies', getCaseStudies);
|
||||
router.get('/content/feedback', getFeedback);
|
||||
router.get('/content/articles', getArticles);
|
||||
router.get('/content/articles/:slug', getArticleBySlug);
|
||||
router.get('/content/events', getEvents);
|
||||
router.get('/content/gallery', getGallery);
|
||||
|
||||
module.exports = router;
|
||||
Reference in new issue
Block a user