import { Router } from '@classes' ; import { Validator } from '@middlewares/validator.middleware' ; import { Guard } from '@middlewares/guard.middleware' ; import { AuthController } from '@controllers/auth.controller' ; import { register , login , refresh , oauthCb , confirm , requestPassword } from '@validations/auth.validation' ; import { ROLE } from '@enums' ; export class AuthRouter extends Router { constructor ( ) { super ( ) ; } description define ( ) { api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiParam apiParam apiParam apiParamExample apiUse apiError apiError apiError apiUse apiError apiError apiUse apiError apiUse apiError apiError apiUse this . router . route ( '/register' ) . post ( Validator . check ( register ) , AuthController . register ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiParam apiParam apiParam apiParamExample apiParamExample apiUse apiError apiError apiUse apiError apiUse apiError apiUse apiError apiError apiUse apiError apiError apiUse this . router . route ( '/login' ) . post ( Validator . check ( login ) , AuthController . login ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiSuccess apiSuccessExample apiError apiError apiUse apiError apiUse this . router . route ( '/logout' ) . post ( Guard . authorize ( [ ROLE . admin , ROLE . user ] ) , AuthController . logout ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiParam apiParamExample apiUse apiError apiError apiUse apiError apiUse apiError apiUse apiError apiError apiUse this . router . route ( '/confirm' ) . patch ( Validator . check ( confirm ) , AuthController . confirm ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiParam apiParamExample apiSuccess apiSuccessExample apiError apiUse apiError apiError apiUse this . router . route ( '/request-password' ) . get ( Validator . check ( requestPassword ) , AuthController . requestPassword ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiParam apiParam apiParamExample apiUse apiError apiUse apiError apiError apiUse apiError apiUse apiError apiError apiUse this . router . route ( '/refresh-token' ) . post ( Validator . check ( refresh ) , AuthController . refresh ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiUse apiError apiError apiUse this . router . route ( '/facebook' ) . get ( Guard . oAuth ( 'facebook' ) ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiUse apiError apiUse apiError apiUse apiError apiUse apiError apiError apiUse this . router . route ( '/facebook/callback' ) . get ( Validator . check ( oauthCb ) , Guard . oAuthCallback ( 'facebook' ) , AuthController . oAuth ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiUse apiError apiError apiUse this . router . route ( '/google' ) . get ( Guard . oAuth ( 'google' ) , AuthController . oAuth ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiUse apiError apiUse apiError apiUse apiError apiUse apiError apiError apiUse this . router . route ( '/google/callback' ) . get ( Validator . check ( oauthCb ) , Guard . oAuthCallback ( 'google' ) , AuthController . oAuth ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiUse apiError apiError apiUse this . router . route ( '/github' ) . get ( Guard . oAuth ( 'github' ) , AuthController . oAuth ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiUse apiError apiUse apiError apiUse apiError apiUse apiError apiError apiUse this . router . route ( '/github/callback' ) . get ( Validator . check ( oauthCb ) , Guard . oAuthCallback ( 'github' ) , AuthController . oAuth ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiUse apiError apiError apiUse this . router . route ( '/linkedin' ) . get ( Guard . oAuth ( 'linkedin' ) , AuthController . oAuth ) ; api apiDescription apiVersion apiName apiGroup apiPermission apiUse apiUse apiError apiUse apiError apiUse apiError apiUse apiError apiError apiUse this . router . route ( '/linkedin/callback' ) . get ( Validator . check ( oauthCb ) , Guard . oAuthCallback ( 'linkedin' ) , AuthController . oAuth ) ; } }