From b355dcf04248c85410416aa42960a15d9a14d2f7 Mon Sep 17 00:00:00 2001 From: Behzad-rabiei Date: Tue, 21 Jan 2025 07:42:39 +0100 Subject: [PATCH] chore: add telegram handle callback route --- src/controllers/auth.controller.ts | 19 ++++++++++++------- src/routes/v1/auth.route.ts | 6 +++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/controllers/auth.controller.ts b/src/controllers/auth.controller.ts index bebda8c..015e505 100644 --- a/src/controllers/auth.controller.ts +++ b/src/controllers/auth.controller.ts @@ -1,13 +1,13 @@ -import httpStatus from 'http-status'; import { Request, Response } from 'express'; -import config from '../config'; -import { discord } from '../config/oAtuh2'; -import { userService, authService, tokenService, discordServices } from '../services'; -import { catchAsync } from '../utils'; +import httpStatus from 'http-status'; import querystring from 'querystring'; -import { generateState } from '../config/oAtuh2'; -import { ISessionRequest } from '../interfaces'; + +import config from '../config'; import logger from '../config/logger'; +import { discord, generateState } from '../config/oAtuh2'; +import { ISessionRequest } from '../interfaces'; +import { authService, discordServices, tokenService, userService } from '../services'; +import { catchAsync } from '../utils'; const discordAuthorize = catchAsync(async function (req: ISessionRequest, res: Response) { const state = generateState(); @@ -78,9 +78,14 @@ const generateToken = catchAsync(async function (req: Request, res: Response) { res.send(token); }); +const telegramAuthorizeCallback = catchAsync(async function (req: Request, res: Response) { + console.log(req.body, req.query, req.params); + res.send('Hi'); +}); export default { discordAuthorize, discordAuthorizeCallback, + telegramAuthorizeCallback, refreshTokens, logout, generateToken, diff --git a/src/routes/v1/auth.route.ts b/src/routes/v1/auth.route.ts index d88b4ae..625ea8d 100644 --- a/src/routes/v1/auth.route.ts +++ b/src/routes/v1/auth.route.ts @@ -1,12 +1,16 @@ import express from 'express'; + import { authController } from '../../controllers'; +import { auth, validate } from '../../middlewares'; import { authValidation } from '../../validations'; -import { validate, auth } from '../../middlewares'; + const router = express.Router(); // Routes router.get('/discord/authorize', authController.discordAuthorize); router.get('/discord/authorize/callback', authController.discordAuthorizeCallback); +router.get('/telegram/authorize/callback', authController.discordAuthorizeCallback); + router.post('/generate-token', auth(), validate(authValidation.generateToken), authController.generateToken); router.post('/logout', validate(authValidation.logout), authController.logout); router.post('/refresh-tokens', validate(authValidation.refreshTokens), authController.refreshTokens);