Skip to content

Commit

Permalink
chore: add telegram handle callback route
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Jan 21, 2025
1 parent d4c0c61 commit b355dcf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion src/routes/v1/auth.route.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit b355dcf

Please sign in to comment.