REFACTOR: Project Pattern and AuthClient (DUC)

This commit is contained in:
Victor Radael
2022-03-14 10:35:03 -03:00
parent 2f8d9b9550
commit 363bc8b350
163 changed files with 2544 additions and 4138 deletions
+17 -24
View File
@@ -2,29 +2,22 @@ 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!' });
}
};
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();
}
});
console.log(verify_response);
} catch (error) {
response.status(401).send({ message: 'Authentication Failed!' });
}
};
}