- Routers `AuthRouter`, `CatalogRouter`, and `RentRouter` are used in the application in `src/app.ts` with error handling. - The router files under `src/routes/auth`, `src/routes/catalog`, and `src/routes/rent` are renamed to `authRouter.ts`, `catalogRouter.ts`, `rentRouter.ts` respectively. - The default exports in these router files have been updated to reflect their new names. - The imports in `src/routes/index.ts` are updated according to the renamed files. Signed-off-by: Mathis <yidhra@tuta.io>
38 lines
900 B
TypeScript
38 lines
900 B
TypeScript
import express, {type Router} from "express";
|
|
import UserGuard from "@validators/UserGuard";
|
|
import AdminGuard from "@validators/AdminGuard";
|
|
import AuthController from "@controllers/auth.controller";
|
|
|
|
|
|
const AuthRouter: Router = express.Router();
|
|
|
|
AuthRouter.route('/login').post(AuthController.login)
|
|
AuthRouter.route('/register').post(AuthController.register)
|
|
|
|
// PATCH
|
|
//TODO - To test
|
|
AuthRouter.route('/me')
|
|
.patch(UserGuard, AuthController.editUser)
|
|
|
|
// GET
|
|
AuthRouter.route('/me')
|
|
.get(UserGuard, AuthController.getSelf)
|
|
|
|
// DELETE
|
|
AuthRouter.route('/me')
|
|
.delete(UserGuard, AuthController.deleteSelf)
|
|
|
|
|
|
// GET
|
|
AuthRouter.route('/all')
|
|
.get(AdminGuard, AuthController.getAllUsers)
|
|
|
|
|
|
// GET
|
|
AuthRouter.route('/user/:targetId')
|
|
.get(AdminGuard, AuthController.getUser)
|
|
.patch(AdminGuard, AuthController.editUser)
|
|
.delete(AdminGuard, AuthController.deleteUser)
|
|
|
|
|
|
export default AuthRouter |