Newer
Older
import { Logger, ForbiddenException } from '@nestjs/common';
export function microserviceMiddleware(req, res, next) {
Logger.log('[-] Untokenise middleware called');
if (req.headers['x-consumer-groups']) {
const arr = req.headers['x-consumer-groups'].split(',');
arr.map(e => e.trim());
const group = arr.find(e => e === 'microservice');
if (group === undefined) {
throw new ForbiddenException('You can\'t access this ressource.');
} else {
next();
}
} else {
throw new ForbiddenException('You can\'t access this ressource.');
}
}