fd4e324571
- Added customer profile controller with endpoints for retrieving, updating, and deactivating user profiles. - Introduced address model and routes for managing user addresses. - Created business application model and service for handling business applications, including approval and rejection processes. - Developed business contact and credit account models to support business customer functionalities. - Implemented settlement term model for managing payment terms. - Added email templates for business application notifications (approved, rejected, received, and status changes). - Enhanced validation schemas for customer and business inputs to ensure data integrity. - Created unit tests for business application service and validation schemas to ensure functionality and correctness. - Added migration scripts to set up new database tables and columns for customer and business features.
77 lines
1.8 KiB
JavaScript
77 lines
1.8 KiB
JavaScript
/**
|
|
* Copyright (c) 2026 Niolla
|
|
* All rights reserved.
|
|
*
|
|
* This source code is proprietary and confidential.
|
|
* Unauthorized copying, modification, distribution, or use
|
|
* of this file, via any medium, is strictly prohibited.
|
|
*/
|
|
|
|
// app/routes/user.routes.js
|
|
|
|
const express = require("express");
|
|
const router = express.Router();
|
|
const userController = require("../controllers/user.controller");
|
|
const {
|
|
authenticate,
|
|
} = require("../middleware/auth.middleware");
|
|
|
|
const { authorizedAccountType, checkPermission } = require("../middleware/permission.middleware");
|
|
const PERMISSIONS = require("../constants/permissions");
|
|
const customerProfile = require("../controllers/customerProfile.controller");
|
|
const validate = require("../middleware/validate.middleware");
|
|
const customerSchemas = require("../validation/customer.schemas");
|
|
|
|
router.get("/me", authenticate, userController.getCurrentUser);
|
|
router.patch("/me", authenticate, userController.updateCurrentUser);
|
|
router.post("/me/deactivate", authenticate, validate(customerSchemas.deactivate), customerProfile.deactivate);
|
|
|
|
|
|
router.post(
|
|
"/",
|
|
// authenticate,
|
|
// authorizedAccountType(["admin"]),
|
|
userController.createNewUser
|
|
);
|
|
|
|
router.post(
|
|
"/verify-email",
|
|
userController.verifyEmail
|
|
);
|
|
|
|
router.get(
|
|
"/profile",
|
|
authenticate,
|
|
userController.userProfile
|
|
);
|
|
|
|
router.get(
|
|
"/",
|
|
authenticate,
|
|
authorizedAccountType(["admin", "superadmin"]),
|
|
userController.getAllUsers
|
|
);
|
|
|
|
// router.get(
|
|
// "/:id",
|
|
// authenticate,
|
|
// authorizedAccountType(["admin", "management", "team_head", "user"]),
|
|
// userController.getUserById
|
|
// );
|
|
|
|
router.patch(
|
|
"/:id",
|
|
authenticate,
|
|
authorizedAccountType(["superadmin"]),
|
|
userController.updateUser
|
|
);
|
|
|
|
router.delete(
|
|
"/:id",
|
|
authenticate,
|
|
authorizedAccountType(["superadmin"]),
|
|
userController.deleteUser
|
|
);
|
|
|
|
module.exports = router;
|