-first commit

This commit is contained in:
2025-11-11 12:36:06 +07:00
commit b99c214434
5683 changed files with 713336 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import express from 'express'
import { loginController } from '../controllers/loginController.js'
import { authMiddleware } from '../middlewares/auth.js'
import { OtpController } from '../../src/controllers/otpController/otpcontroller.js'
import { OtpVerifyController } from '../../src/controllers/otpController/otpVerifycontroller.js'
import { RegisterController } from '../controllers/registercontroller.js';
import { VerifyEmailController } from '../controllers/verifyemailcontroller.js';
import { ResetPasswordController } from '../controllers/otpController/resetpasswordcontroller.js';
// 🧱 Controller Instances
const registerController = new RegisterController();
const verifyEmailController = new VerifyEmailController();
const resetPasswordController = new ResetPasswordController();;
const router = express.Router()
const controller_login_post = new loginController()
const otpController = new OtpController()
const otpVerifyController = new OtpVerifyController()
router.post('/login/login', async (req, res) => {const result = await controller_login_post.onNavigate(req, res); return res.json(result)})
router.post('/login/otp/send', async (req, res) => {
const result = await otpController.onSendOtp(req, res)
if (result) return res.json(result)
})
router.post('/login/register', async (req, res) => {
const result = await registerController.onNavigate(req, res);
if (result) return res.json(result);
});
router.get('/login/verify-email', async (req, res) => {
const result = await verifyEmailController.onVerifyEmail(req, res);
if (result?.code && result.code !== '200') return res.status(400).send(result.message_th);
// ถ้า controller ส่ง HTML string กลับมา → render ตรง ๆ
if (typeof result === 'string') return res.send(result);
return res.json(result);
});
router.post('/login/reset-password', async (req, res) => {
const result = await resetPasswordController.onNavigate(req, res);
if (result) return res.json(result);
});
router.post('/login/otp/verify', async (req, res) => {
const result = await otpVerifyController.onNavigate(req, res)
if (result) return res.json(result)
})
export default router