import { Request, Response, NextFunction } from 'express'; import axios from 'axios'; import { NestMiddleware } from '@nestjs/common'; export class LoggerMiddleware implements NestMiddleware{ use = async ( request: Request, response: Response, next: NextFunction ) => { try { const verify_response = await axios.post( `${process.env.DEV_URL}/user/verify`, { "token":request.get('Authorization')} ).then(response =>{ if(response.data.message == "Success"){ next() } }) } catch (error) { response.status(401).send({ message: 'Authentication Failed!' }); } }; }