const express = require('express');
const router = express.Router();
const multer = require('multer');

const rateLimit = require('express-rate-limit');
const upload = multer();

const Authentication = require('../controllers/Authentication')

const ipLock = require('../middleware/ipLockMiddleware');
const ipLockWare = ipLock.ipLockMiddleware;

router.post('/auth/login', Authentication.login)
router.get('/auth/getAdmin', Authentication.getAdmin)
router.get('/device/getDevices', Authentication.getDevices)
router.get('/device/getDevice', Authentication.getDevice)
router.get('/device/getDeviceInfo', Authentication.getDeviceInfo)
router.get('/device/testDevice', Authentication.testDevice)

router.post('/device/createDevice', Authentication.createDevice)
router.post('/device/editDevice', Authentication.editDevice)
router.post('/device/deleteDevice', Authentication.deleteDevice)

router.get("/person/list", Authentication.personList);
router.post("/person/find", Authentication.personFind);
router.post("/addPerson", Authentication.addPerson);

router.post("/face/find", Authentication.faceFind);
router.post("/face/add", Authentication.faceAdd);

router.post("/record/list", Authentication.recordList);
router.post("/access-log", Authentication.accessLog);
router.post("/getDeviceConfig", Authentication.getDeviceConfig);
router.post("/setDeviceConfig", Authentication.setDeviceConfig);
router.post("/createEmployeeSignupLink", Authentication.createEmployeeSignupLink);
router.post("/signup/check", Authentication.checkLink);
router.post("/signup/submit", Authentication.submitSignup);
router.post("/signupSubmitWithDoc", Authentication.submitSignupWithDoc);
router.post("/submitCustomerSignupWithDoc", Authentication.submitCustomerSignupWithDoc);

router.post("/deletePerson", Authentication.deletePerson);

router.post("/syncEmployee", Authentication.syncEmployee);
router.post("/syncAllEmployees", Authentication.syncAllEmployees);

router.get("/listPeople", Authentication.listPeople)
router.post("/viewPerson", Authentication.viewPerson);
router.get("/listReviews", Authentication.listReviews)
router.post("/reviewPerson", Authentication.reviewPerson);
const otpLoginLimiter = rateLimit({
    windowMs: 1 * 60 * 1000, // 1 minutes
    max: 5, // Limit each IP to 1 requests per windowMs
    message: 'Too many requests from this IP, please try again later.',
});
// Route to get all admins
// router.get('/admins', authController.getAllAdmins);


module.exports = router;