mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-08 05:29:08 +00:00
31 lines
732 B
TypeScript
31 lines
732 B
TypeScript
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!' });
|
|
}
|
|
};
|
|
|
|
}
|