-first commit
This commit is contained in:
48
exthernal-accountingwep-api/src/routes/route.js
Normal file
48
exthernal-accountingwep-api/src/routes/route.js
Normal file
@@ -0,0 +1,48 @@
|
||||
// ===================================================
|
||||
// ⚙️ route.js (Nuttakit Pattern vFinal++++)
|
||||
// ===================================================
|
||||
import express from 'express'
|
||||
import { loginController } from '../controllers/logincontroller.js'
|
||||
import { authMiddleware } from '../middlewares/auth.js'
|
||||
import { sendResponse } from '../utils/response.js'
|
||||
|
||||
const router = express.Router()
|
||||
const controller_login_post = new loginController()
|
||||
|
||||
// ===================================================
|
||||
// 🔹 LOGIN ปกติ
|
||||
// ===================================================
|
||||
router.post('/login', async (req, res) => {
|
||||
const data = await controller_login_post.onNavigate(req, res)
|
||||
if (data)
|
||||
return sendResponse(res, 200, 'เข้าสู่ระบบสำเร็จ', 'Login success', data)
|
||||
})
|
||||
|
||||
// ===================================================
|
||||
// 🔹 BIOMETRIC LOGIN
|
||||
// ===================================================
|
||||
router.post('/biometric/login', async (req, res) => {
|
||||
const data = await controller_login_post.onBiometricLogin(req, res)
|
||||
if (data)
|
||||
return sendResponse(res, 200, 'เข้าสู่ระบบผ่าน Biometric สำเร็จ', 'Biometric login succeed', data)
|
||||
})
|
||||
|
||||
// ===================================================
|
||||
// 🔹 BIOMETRIC REGISTER (ต้อง login ก่อน)
|
||||
// ===================================================
|
||||
router.post('/biometric/register', authMiddleware, async (req, res) => {
|
||||
const data = await controller_login_post.onBiometricRegister(req, res)
|
||||
if (data)
|
||||
return sendResponse(res, 200, 'ผูก Biometric สำเร็จ', 'Biometric registered', data)
|
||||
})
|
||||
|
||||
// ===================================================
|
||||
// 🔹 TOKEN RENEW (ต่ออายุ Token)
|
||||
// ===================================================
|
||||
router.post('/token/renew', authMiddleware, async (req, res) => {
|
||||
const data = await controller_login_post.onRenewToken(req, res)
|
||||
if (data)
|
||||
return sendResponse(res, 200, 'ออก Token ใหม่สำเร็จ', 'Token renewed', data)
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user